set_preference ( "_proxy_settings", True ) # Other configurations. If configured separately, it is not necessary to set this item because it defaults to False. port ) # All protocols share an ip and port. set_preference ( "", 1 ) # ip and its port number are configured as http protocol proxy Chrome (chrome_options =options ) firefox proxy profile = FirefoxProfile ( ) # http proxy Path = r "/Users/xxx/browsermob-proxy-2.1.4/bin/browsermob-proxy" # Initialize a proxy Manager service and listen on port 8180 """ # Proxy service (here is the call file for macOX) Then the basic usage is browsermob-proxy function. So we need to call the corresponding files in bin directory according to our own platform. Initialize browsermob-proxyįirst, download the browsermob-proey reless package, as the project is implemented in java. Through its proxy service interface, it is set to selenium, so that when we operate the page, we can grab some asynchronous request lists (http, https) of the page. perform ( ) Grab the networkįirst, selenium needs to rely on third-party component browsermobproxy to intercept the network list of pages. execute_script ( "window.scrollBy(0, 700)" ) # Simulation mode # headless may fail, or you may need to click on it before.ĪctionChains (self. move_by_offset (xoffset =x, yoffset =y ). perform ( ) # Move the specified pixelĪctionChains (self. perform ( ) # Lifting keyĪctionChains (self. execute_script ( "arguments.click() ", element ) # Click and hold a label (not required)ĪctionChains (self. You can also use wait s with timeouts to get Tags self. find_elements_by_xpath ( "//div/div/a" ) #. find_element_by_class_name ( "user-tab" ) # Multiple If it is not found, an exception message will be reported. There are many ways to choose, according to the tag id, class, class selector, xpath and so on. driver, 10 ) Open web page # Empty cookies Firefox (firefox_profile =profile ) # Setting timeout time set_preference ( '', 2 ) # Disable loading pictures # Open driver Chrome (chrome_options =options ) # Set wait for timeout add_experimental_option ( 'excludeSwitches', ) # Open driver add_argument ( '-disable-cache' ) # Headless mode add_argument ( '-ignore-certificate-errors' ) Chrome options = ChromeOptions ( ) # Ignore https warnings
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |