mdc101 15 Posted December 5, 2011 Report Share Posted December 5, 2011 Hi GuysI am sure this is easy but I cant seem to figure out how to count the rows in a txt file. Here is the scenarioI have a list of txt file of proxies and a txt file of user agents. I have created a command that harvests the user agents.In the following code is set the proxy. I then want to set the user agent.Instead of running the user agent scraper command every time I want to wrap the command with an if statement that checks to see if the file exists first and if it exists it has more than one row. if it does not exist then the command runs and creates it. How do I wrap the two commands UserAgentHarvestor()MobileUserAgentHarvestor() The end result I am looking for is to just call the command when I need the proxy and user agent set but want the process to manage itself. I will then drop this command into a loop so everytime the loop runs a new user agent and proxy is used.I have put the code here so if anyone is looking for something similar they welcome to use it. Any suggestions will be appreciated as well of course. Thanks for any help define ManageProxies { if($comparison(#ProxyOn, "=", "true")) { then { if($comparison(#UsePrivateProxies, "=", "true")) { then { set(#ProxyList, #PrivateProxies, "Global") } else { set(#ProxyList, #Proxies, "Global") } } clear list(%proxies) add list to list(%proxies, $list from file(#ProxyList), "Delete", "Global") set(#ProxyListPosition, 0, "Global") change proxy($list item(%proxies, #ProxyListPosition)) run javascript("location.reload(true);") increment(#ProxyListPosition) } } if($comparison(#UseBrowserAgent, "=", "true")) { then { UserAgentHarvestor() clear list(%BrowserUserAgents) add list to list(%BrowserUserAgents, $list from file("{$special folder("Desktop")}\\DWS-projects\\_appData\\browser-user-agent-list.txt"), "Delete", "Global") set(#position, $rand(0, 10), "Global") set user agent($list item(%BrowserUserAgents, #position)) else if($comparison(#UseMobileAgent, "=", "true")) { MobileUserAgentHarvestor() clear list(%MobileUserAgents) add list to list(%MobileUserAgents, $list from file("{$special folder("Desktop")}\\DWS-projects\\_appData\\mobile-user-agent-list.txt"), "Delete", "Global") set(#position, $rand(0, 10), "Global") set user agent($list item(%MobileUserAgents, #position)) else { set user agent("Internet Explorer 10") } } } }} Quote Link to post Share on other sites
mdc101 15 Posted December 5, 2011 Author Report Share Posted December 5, 2011 One thing I have noted is my proxy's are not running through the list. They are sticking on the first row. Should I use a random function to garb a random proxy Quote Link to post Share on other sites
mdc101 15 Posted December 6, 2011 Author Report Share Posted December 6, 2011 Any ideas guys? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.