Chris M 55 Posted March 25, 2015 Report Share Posted March 25, 2015 Hey guys, I wanted to share this code with those who own the CBrowser plugin and want to use updated random user agents in theirbots. Enjoy! download file("http://techpatterns.com/downloads/firefox/useragentswitcher.xml","{$special folder("Desktop")}\\useragentswitcher.xml") wait(1) clear list(%Useragents) add list to list(%Useragents,$list from text($find regular expression($read file("{$special folder("Desktop")}\\useragentswitcher.xml"),"(?<=useragent=\").*?(?=\")")," "),"Delete","Global") save to file("{$special folder("Desktop")}\\Useragents.txt",%Useragents) set(#user_agent,$random list item($list from file("{$special folder("Desktop")}\\Useragents.txt")),"Global") plugin command("Communication.dll", "CBrowser Container", "PhantomJS", "", $plugin function("Communication.dll", "$CBrowser Set User Agent", #user_agent)) { plugin command("Communication.dll", "CBrowser Navigate", "http://whatsmyuseragent.com/") plugin command("Communication.dll", "CBrowser Save Screenshot", "C:\\Users\\Chris\\Desktop\\screenshot.png") } 1 Quote Link to post Share on other sites
diskwizz 24 Posted March 25, 2015 Report Share Posted March 25, 2015 (edited) Nice little trick! Try this regex out "(?<=useragent=\")(?=.*Chrome|Mozilla|Opera)(?!.*Mobile).*?(?=\")" it filters all user agents that contain Chrome, Mozilla, and Opera, but it leaves out all that contain Mobile. Edited March 25, 2015 by diskwizz 1 Quote Link to post Share on other sites
Chris M 55 Posted March 25, 2015 Author Report Share Posted March 25, 2015 Hey Diskwizz, What would be the best way to rotate the most common browser sizes and use it inthe plugin with this code so that every new window is a random size? download file("http://techpatterns.com/downloads/firefox/useragentswitcher.xml","{$special folder("Desktop")}\\useragentswitcher.xml") wait(1) clear list(%Useragents) add list to list(%Useragents,$list from text($find regular expression($read file("{$special folder("Desktop")}\\useragentswitcher.xml"),"(?<=useragent=\\\")(?=.*Chrome|Mozilla|Opera)(?!.*Mobile).*?(?=\\\")")," "),"Delete","Global") save to file("{$special folder("Desktop")}\\Useragents.txt",%Useragents) set(#user_agent,$random list item($list from file("{$special folder("Desktop")}\\Useragents.txt")),"Global") plugin command("Communication.dll", "CBrowser Container", "PhantomJS", "", "{$plugin function("Communication.dll", "$CBrowser Set User Agent", #user_agent)}{$plugin function("Communication.dll", "$CBrowser Window Size", 1024, 920)}") { plugin command("Communication.dll", "CBrowser Navigate", "http://whatsmyuseragent.com/") plugin command("Communication.dll", "CBrowser Save Screenshot", "C:\\Users\\Chris\\Desktop\\screenshot.png") } 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.