Requests is a Python lightweight HTTP client library that is much more elegant than the Python standard library. Next through this article to introduce the PYTHON3 use requests flash memory method, learn it together.
Install requests using the following command
Copy the Code code as follows:
PIP Install
This article mainly introduces the use of IP proxy pool Python3 requests in the random generation of IP instances, has a certain reference value, now share to everyone, the need for friends can refer to
Don't say anything, just go to the code!
# Encoding:utf-8import Requests # import requests module used to access
requests# will report a certificate error when accessing HTTPS (caused by Sslerror (Sslcertverificationerror (1, ' [ssl:certificate_verify_failed]), Can not be verified when sending a request. #屏蔽waring信息 #requests.packages.urllib3.disable_warnings () #一般的get请求方法 #myrequest = Requests.get (r "https:// Www.baidu.com ", Verify=false) #print (myrequest.headers) #准备请求数据myUrl = r" https://www.cnblogs.com/mpp0905/p/9264465. HTML "MyHeader = {" Content-type
the documentation: https://www.cnblogs.com/shapeL/p/9037035.html"2" request after the return of the results asserted: assertequal (), and so on, the assertion method is many, can be online query(2) In practice, some parameters or methods must be described before executing the use case, which involves the use of Setup, TearDown, SetupClass, Teardownclass"1" setup (): Each test function runs before running; Teardown (): Executes after each test function is run; SetupClass (): Must use @classmetho
There are many convenient methods in the Reuqests library, such as getting a Web page in get, and in the requests library is the method get (), on the codeImport= requests.get ('https://www.baidu.com')print (Type (r)) Print (R.status_code) Print (Type (r.text)) Print (R.text) Print (r.cookies)Equivalent to Urlopen method, get a response object, and then output his type, status code, the type of the corresponding body, content and cookiesRequests there
Use of requests, beautifulsoup, Urllib, etc., the specific code is as follows.#-*-coding:utf-8-*-"""Created on Sat 09:13:07 2018@author:brave_manemail: [email protected] Here's a hole first. There is no 404 hole in the page. First, we refer to a page that contains 30 complaints, called a main interface. Each main interface is comprised of 30 complaint stickers, we get a hyperlink to each complaint post, and then, the obtained hyperlink is uploaded to
,'WB') Runner=HTMLTESTRUNNERCN.HTMLTESTREPORTCN (Stream=FP, title='XXX Interface Automation test report', Description='Description section of the report', Tester='Tested by') Runner.run (Suite) fp.close ()You can see that an HTML file was generated under the report folder. Folder to open this HTML fileYou can see the effect of generating reports, and the fields in the code are easy to see from the report. Don't bother talking.Add a comment block to the first line of the class and test function,
Several Requests library requests: Requests library requests
The content of this article Source: https://www.dataquest.io/mission/117/working-with-apis
Data source: https://en.wikipedia.org/wiki/International_Space_Station
Abstract: The github repository is operated through the r
the Get and post in the header are two ways of requesting, synchronous and asynchronous are implementations, and get methods are synchronous and asynchronous, and there are two kinds of post. A little bit of web knowledge, to get and post should not be unfamiliar, often said request processing response, basically request is the two buddies, HTTP is the first definition of the server interaction with the way there are eight kinds, but with the evolution of time, now basically use only two of thes
Synchronous requests, asynchronous requests, GET requests, POST requests for IOS, and iosget
Original link here: http://blog.csdn.net/liulala16/article/details/8271673
1. synchronous requests can request data from the Internet. Once a synchronous request is sent, the progra
Synchronous requests, asynchronous requests, GET requests, and POST requests for IOS
1. synchronous requests can request data from the Internet. Once a synchronous request is sent, the program stops user interaction until the server returns data,
2. asynchronous
1. synchronous requests can request data from the Internet. Once a synchronous request is sent,ProgramUser interaction stops until the server returns data,2. asynchronous requests do not block the main thread, but create a new thread to operate. After the user sends an asynchronous request, the user can still operate the UI, and the program can continue to run.3. For a GET request, write the parameters dire
. Proxy method for asynchronous requests
This method is called when a server response is received
-(void) connection: (Nsurlconnection *) connection didreceiveresponse: (Nsurlresponse *) Response
{
Nshttpurlresponse *res = (Nshttpurlresponse *) response;
NSLog (@ "%@", [res allheaderfields]);
Self.receivedata = [Nsmutabledata data];
}
Called when the server transmits data, this method executes several times based on the size of the data
-(void
default, if you decide to write too many rows, do not want each row with/n, you can use the "" "..." form to write:Print ("' Line1Line2Line3 ")The output is the same as the end Plus/n:Line1Line2Line3Boolean values can be operated with and, or, and not. The and operation is the same as the operation, and only all the results of the true,and operation are true; or operations are or operations, as long as one of them is the result of a true,or operation is a true not operation is a non-operation,
Performance Comparison of multiprocessing, threading and gevent in python3 ---- process pool, thread pool, and process Pool performance comparison, python3
At present, computer programs generally encounter two types of I/O: Hard Disk I/O and network I/O. I analyzed the process, thread, and coroutine efficiency in python3 for network I/O scenarios. The process use
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.