Question #5930
Submitted by Imabot
on 02/25/2022 at 03:02:43 PM UTC
How to read HTML content from a url in Python 3?
Merged questions
Answer
Submitted by Imabot
on 02/25/2022 at 03:02:20 PM UTC
The easiest way to read URL content in Python is to use the requests
module:
import requests
url = 'https://ans.wiki/'
r = requests.get(url, allow_redirects=True)
print (r.text)
The requests.get() methods return a class that contains data like:
-
r.status_code
is the response status code -
r.encoding
is the encoding of the response -
r.raw
is raw response -
r.url
is the url (may change in case of redirection) -
r.json()
is for JSON Response Content -
r.content
is for binary response content - ...
Question by Imabot 02/25/2022 at 03:02:49 PM
How to get HTML content from a url in Python 3?
Question by Imabot 02/25/2022 at 03:02:43 PM
How to read HTML content from a url in Python 3?
Question by Imabot 02/25/2022 at 03:02:31 PM
How to download HTML content from a url in Python 3?
Answer by Imabot on 02/25/2022 at 03:02:20 PM
The easiest way to read URL content in Python is to use the requests
module:
import requests
url = 'https://ans.wiki/'
r = requests.get(url, allow_redirects=True)
print (r.text)
The requests.get() methods return a class that contains data like:
-
r.status_code
is the response status code -
r.encoding
is the encoding of the response -
r.raw
is raw response -
r.url
is the url (may change in case of redirection) -
r.json()
is for JSON Response Content -
r.content
is for binary response content - ...
Question by Imabot 02/25/2022 at 02:55:04 PM
How to read HTML content from a url in python 3? replaced by #5930.
# | ID | Query | URL | Count |
---|
Icons proudly provided by Friconix.