Reptile

requests module

import requests

response
=requests.get('https://www.baidu .com')
print(response.text)

share picture

import requests

# requests.get()
#
requests.post()
#
requests.head()
#
Like get, post, and head all return request()
response=requests.request(
url
='https://www.zhihu.com',
method
='get',
# params={}, #parameters passed on url span>
# data={} #post default content-type
# json={} #content-type is passed in application/json format
headers={
# indicates which method is requested, here is the simulation browser span>
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit /537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36',
}
)
print(response.text)

The more important headers Parameters

share picture

import requests

response
=requests.request(
url
='https://i.cnblogs.com/Configure .aspx',
method
='get',
cookies
={'.CNBlogsCookie':'xxx'}
)
print(response.text)

The more important cookie Parameters

share picture

def request(method, url, **kwargs):

"""Constructs and sends a :class:`Request `.

:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``('name': ('filename', fileobj))``) for multipart encoding upload .
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How long to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) ` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert‘, ‘key’) pair.
:return: :class:`Response ` object
:rtype: requests.Response

Usage::

>>> import requests
>>> req = requests.request(‘GET’, ‘http://httpbin.org/get’)

"""

# By using the'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)

More parameters

Other parameters

beautifulsoup module

From https://www.cnblogs.com/yuanchenqi/articles/7617280.html

import requests

response
=requests.get('https://www.baidu .com')
print(response.text)

share picture

import requests

# requests.get()
#
requests.post()
#
requests.head()
#
Like get, post, and head all return request()
response=requests.request(
url
='https://www.zhihu.com',
method
='get',
# params={}, #parameters passed on url span>
# data={} #post default content-type
# json={} #content-type is passed in application/json format
headers={
# indicates which method is requested, here is the simulation browser span>
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit /537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36',
}
)
print(response.text)

The more important headers Parameters

import requests

# requests.get()
#
requests.post()
#
requests.head()
#
Like get, post, and head all return request()
response=requests.request(
url
='https://www.zhihu.com',
method
='get',
# params={}, #parameters passed on url span>
# data={} #post default content-type
# json={} #content-type is passed in application/json format
headers={
# indicates which method is requested, here is the simulation browser span>
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit /537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36',
}
)
print(response.text)

share picture

import requests

response
=requests.request(
url
='https://i.cnblogs.com/Configure .aspx',
method
='get',
cookies
={'.CNBlogsCookie':'xxx'}
)
print(response.text)

The more important cookie Parameters

import requests

response
=requests.request(
url
='https://i.cnblogs.com/Configure .aspx',
method
='get',
cookies
={'.CNBlogsCookie':'xxx'}
)
print(response.text)

share picture

def request(method, url, **kwargs):

"""Constructs and sends a :class:`Request `.

:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``('name': ('filename', fileobj))``) for multipart encoding upload .
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How long to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) ` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert‘, ‘key’) pair.
:return: :class:`Response ` object
:rtype: requests.Response

Usage::

>>> import requests
>>> req = requests.request(‘GET’, ‘http://httpbin.org/get’)

"""

# By using the'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)

More parameters

Other parameters

def request(method, url, **kwargs):

"""Constructs and sends a :class:`Request `.

:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``('name': ('filename', fileobj))``) for multipart encoding upload .
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How long to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) ` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert‘, ‘key’) pair.
:return: :class:`Response ` object
:rtype: requests.Response

Usage::

>>> import requests
>>> req = requests.request(‘GET’, ‘http://httpbin.org/get’)

"""

# By using the'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)

More parameters

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2052 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.