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

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

新聞中心

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

說明

10年積累的成都網站設計、成都做網站、外貿網站建設經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站策劃后付款的網站建設流程,更有青浦免費網站建設讓你可以放心的選擇與我們合作。

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

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

實例

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'
 
        # 從登錄頁面響應中解析出post數據
        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學習指路:創(chuàng)新互聯python教程

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


分享題目:創(chuàng)新互聯Python教程:python scrapy.Request發(fā)送請求的方式
文章鏈接:http://m.5511xx.com/article/ccopsed.html