The use of the python3 standard library httpclient in detail
As shown below:
import , import , import random USER_AGENTS = [ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)", "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)", "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)", "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)", "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)", "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070215 K-Ninja/2.1.1", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/20080705 Firefox/3.0 Kapiko/3.0", "Mozilla/5.0 (X11; Linux i686; U;) Gecko/20070322 Kazehakase/0.4.5", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20", "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52", 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36' ] def get_demo(num,keyword): page = ({'page':num}) params = ({}) headers = {'Referer': '/', 'User-Agent': (USER_AGENTS ) 'Accept - Encoding': 'gzip, deflate', 'Accept - Language': 'zh - CN, zh;q = 0.9', } conn = ("", timeout=10) ("GET", "/?fid=16&"+page, params, headers) r1 = () data = ().decode('gbk') # This will return entire content. content = (keyword) if content != -1: print('bingo:'+page) else: print('try {},status:{}'.format(page, )) def post_demo(): params = ({'qruuid': 'asdf', 'user_uuid': '3423412dfasf'}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "application/json"} conn = ("") ("POST", "/api/qrcode", params, headers) response = () print(, ) if not : data = () print(data, type(('utf-8'))) () if __name__ == '__main__': pass
The above this article on the use of python3 standard library httpclient details is what I share with you all, I hope to be able to give you a reference, but also hope that you support me more.
Related articles
Teach you two steps to solve the problem of slow download speed OR timeout when installing pytorch on conda!
This article introduces a two-step approach to solving the problem of slow download speed or timeout when installing pytorch on conda, the use of Tsinghua mirrors can greatly reduce the time of the installation, the need for friends can refer to the following2023-03-03The most complete collection of the latest Pygame zero
This article introduces the latest Pygame zero most complete collection, through this article to learn to know update function is pygame zero comes with a function that runs 60 times per second, of course, you can also modify, this article through the sample code to give you a very detailed, if you need friends can refer to the next!2022-08-08The best way to implement timed tasks with Python scripts
We are in the daily work, often used to the need for periodic implementation of the task, the following article introduces the best way to achieve timed tasks on Python script, the text through the example code is very detailed, you can refer to the next!2022-05-05Use of the squeeze function, cat function in pytorch
This article introduces the use of pytorch in the squeeze function, cat function, has a good reference value, I hope to help you. If there is an error or not fully considered place, look forward to advice!2021-05-05Want to learn python These are 5 books you must read!
If you want to learn python, these are the 5 books you must read! In this article, we recommend 5 books to learn python, 5 classic books, interested partners can refer to2018-12-12python recursively downloads all files in a folder
This article is mainly for you to introduce the python recursive download folder all the files, with certain reference value, interested partners can refer to it2019-08-08Simple use of the requests library + xpath + lxml in python
This article introduces the python requests library + xpath + lxml simple to use, the text of the sample code through the introduction of the very detailed, for everyone's learning or work has a certain reference value of learning, the need for friends here with the editor to learn together!2021-04-04Python higher-order function of filter () function code example
This article introduces the Python high-level function of filter () function code examples, access to a sequence of time, you want to remove some of the contents, to retain a part of the contents of the time you can use the efficient filter () function, the need for friends can refer to the next!2023-07-07jupyter notebook add kernel tutorial
This article introduces the jupyter notebook increase kernel tutorial, with good reference value, I hope to help you. Together follow the editor over to see it2020-04-04pytorch implementation of extracting features with Resnet and saving as txt file
Today I'm sharing a pytorch implementation of the use of Resnet to extract features and save as a txt file, with good reference value, I hope to help you. Together follow the editor over to see it2019-08-08