日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:pythonscrapy模擬登錄的方法

1、requests模塊。直接攜帶cookies請求頁面。

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于網(wǎng)站設計、成都網(wǎng)站設計、華州網(wǎng)絡推廣、微信小程序、華州網(wǎng)絡營銷、華州企業(yè)策劃、華州品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供華州建站搭建服務,24小時服務熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com

找到url,發(fā)送post請求存儲cookie。

2、selenium(瀏覽器自動處理cookie)。

找到相應的input標簽,輸入文本,點擊登錄。

3、scrapy直接帶cookies。

找到url,發(fā)送post請求存儲cookie。

# -*- coding: utf-8 -*-
import scrapy
import re
 
class GithubLoginSpider(scrapy.Spider):
    name = 'github_login'
    allowed_domains = ['github.com']
    start_urls = ['https://github.com/login']
 
    def parse(self, response): # 發(fā)送Post請求獲取Cookies
        authenticity_token = response.xpath('//input[@name="authenticity_token"]/@value').extract_first()
        utf8 = response.xpath('//input[@name="utf8"]/@value').extract_first()
        commit = response.xpath('//input[@name="commit"]/@value').extract_first()
        form_data = {
            'login': 'pengjunlee@163.com',
            'password': '123456',
            'webauthn-support': 'supported',
            'authenticity_token': authenticity_token,
            'utf8': utf8,
            'commit': commit}
        yield scrapy.FormRequest("https://github.com/session", formdata=form_data, callback=self.after_login)
 
    def after_login(self, response): # 驗證是否請求成功
        print(re.findall('Learn Git and GitHub without any code!', response.body.decode()))

以上就是python scrapy模擬登錄的方法,希望對大家有所幫助。更多Python學習指路:創(chuàng)新互聯(lián)python教程

本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。


當前標題:創(chuàng)新互聯(lián)Python教程:pythonscrapy模擬登錄的方法
URL標題:http://www.5511xx.com/article/dhipdhi.html