Analog Login Get Cookie

Source: Internet
Author: User

Analog Login Code

deflogin (): fromSeleniumImportVebdriver Browser= Webdriver. Chrome (executable_path='E:/test/chromedriver.exe')#inside the parentheses is the path of the environment, the window is configured so that it is not possible to use this path .Browser.get ('Http://www.zhihu.com.signin')##访问的页面, which is the page that needs to be landedBrowser.find_element_by_css_selector ('. Sigflow.input'). Send_keys ('Account Number')##输入的帐号和密码, you write more.    #one thing to note here is that you try to put your time in a little bit longer when you type it, and the best thing to do is to divide it into several times.Browser.find_element_by_css_selector ('. Button.input'). Click ()##点击的那个按钮        ImportTime Time.sleep (10)    #Get CookiesCookies =browser.get_cookies ()Print(Cookies) cookie_dict= {}    ImportPickle forCookiesinchCookies:#Write Filef = open ('g:/scrapy/'+cookie['name']+'. Lagou','WB') Pickle.dump (cookie,f) f.close ()#The above is a cookie written to the filecookie_dict[cookie['name']] = cookie['value']        #This is present on the disk.Browser.close ()#Close Browser    return[Scrapy. Request (url=self.start_urls[0],dont_filter=true,cookies =cookie_dict)] #return a cookie to which URL    #Be sure to take care to open the cookie inside the setting.

Analog Login Get Cookie

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.