I want to get HTTP from Python quickly

Asked 2 years ago, Updated 2 years ago, 106 views

What's the fastest way to get HTTP on Python?

After getting, I try to find a string like content = url.get("http://example.com/foo/bar") but I don't know how to get it.

I heard that I can use httplib or urilib, but maybe because I can't speak English, I don't know.

I have to open it. I'm looking for something. I can't open it.

If you know how to use it, please let me know

I'm using Python 2

python http network

2022-09-22 22:17

1 Answers

import urllib2
urllib2.urlopen("http://example.com/foo/bar").read()
import urllib.request
urllib.request.urlopen("http://example.com/foo/bar").read()
import requests
r = requests.get("http://www.naver.com")

print(r.status_code)
print(r.headers)
print(r.content)


2022-09-22 22:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.