资源简介

python使用requests模拟登录带验证码的专利网站demo

资源截图

代码片段和文件信息

import requests
import base64

from bs4 import BeautifulSoup

if __name__ == ‘__main__‘:
    checkHeader = {
        “Host“: “www.pss-system.gov.cn“
        “Proxy-Connection“: “keep-alive“
        “Cache-Control“: “max-age=0“
        “Origin“: “http://www.pss-system.gov.cn“
        “Upgrade-Insecure-Requests“: “1“
        “User-Agent“: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/60.0.3112.90 Safari/537.36“
        “Content-Type“: “application/x-www-form-urlencoded“
        “Accept“: “text/htmlapplication/xhtml+xmlapplication/xml;q=0.9image/webpimage/apng*/*;q=0.8“
        “Referer“: “http://www.pss-system.gov.cn/sipopublicsearch/portal/uiIndex.shtml“
        “Accept-Encoding“: “gzip deflate“
        “Accept-Language“: “zh-CNzh;q=0.8“
    }
    header = {
        “Accept“: “text / html * / *;q = 0.01“
        “Accept-Encoding“: “gzip deflate“
        “Accept-Language“: “zh-CNzh;q=0.8“
        “Content-Type“: “application/x-www-form-urlencoded; charset=UTF-8“
        “User-Agent“: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/60.0.3112.90 Safari/537.36“
    }
    baseUrl = ‘http://www.pss-system.gov.cn/sipopublicsearch/patentsearch/tableSearch-showTableSearchIndex.shtml‘
    checkUrl = ‘http://www.pss-system.gov.cn/sipopublicsearch/wee/platform/wee_security_check‘
    timeUrl = ‘http://www.pss-system.gov.cn/sipopublicsearch/portal/checkLoginTimes-check.shtml‘
    debugUrl = ‘http://www.pss-system.gov.cn/sipopublicsearch/portal/sessionDeBugAC.do‘
    codeurl = ‘http://www.pss-system.gov.cn/sipopublicsearch/portal/login-showPic.shtml‘

    ‘‘‘此处改为大家在专利网注册的账号‘‘‘
    strName = ‘‘
    strPass = ‘‘


    base64Name = str(base64.b64encode(bytes(strNameencoding=‘utf-8‘)) ‘utf-8‘)
    base64Pass = str(base64.b64encode(bytes(strPassencoding=‘utf-8‘)) ‘utf-8‘)
    timeData = {
     

评论

共有 条评论