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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python scrapy.Request發(fā)送請求的方式

說明

10年積累的成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站策劃后付款的網(wǎng)站建設(shè)流程,更有青浦免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

1、使用scrapy.Request()指定method,body參數(shù)發(fā)送post請求。

2、使用scrapy.FormRequest()發(fā)送post請求,也可以發(fā)送表格和ajax請求。

實(shí)例

import scrapy
 
 
class Git2Spider(scrapy.Spider):
    name = 'git2'
    allowed_domains = ['github.com']
    start_urls = ['http://github.com/login']
 
    def parse(self, response):
        username = 'GitLqr'
        password = 'balabala'
 
        # 從登錄頁面響應(yīng)中解析出post數(shù)據(jù)
        token = response.xpath('//input[@name="authenticity_token"]/@value').extract_first()
 
        post_data = {
            'commit': 'Sign in',
            'authenticity_token': token,
            'login': username,
            'password': password,
            'webauthn-support': 'supported',
        }
        print(post_data)
 
        # 針對登錄url發(fā)送post請求
        yield scrapy.FormRequest(
            url='https://github.com/session',
            callback=self.after_login,
            formdata=post_data
        )
 
    def after_login(self, response):
        yield scrapy.Request('https://github.com/GitLqr', callback=self.check_login)
 
    def check_login(self, response):
        print(response.xpath('/html/head/title/text()').extract_first())

以上就是python scrapy.Request發(fā)送請求的方式,希望對大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程

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


當(dāng)前名稱:創(chuàng)新互聯(lián)Python教程:python scrapy.Request發(fā)送請求的方式
新聞來源:http://m.5511xx.com/article/ccopsed.html