[英]requests.get returns <!doctype> instead <Response>
I have an issue with requests.get(). 我对request.get()有问题。 If I paste the URL manually into the code as here:
如果我将网址手动粘贴到代码中,如下所示:
r = requests.get('https://berlin.kauperts.de/Strassen/Igelsteig-12557-Berlin.html')
print(r)
I get: <Response [200]>
. 我得到:
<Response [200]>
。 Which works quite fine. 哪个效果很好。 Instead if I try to ask for the requests out of a list of files as in:
相反,如果我尝试从文件列表中请求请求,如下所示:
indir = '/home/d/Desktop/civiv_hacking/Streetnames/dump/berlin.kauperts.de/Strassen'
for root, dirs, filenames in os.walk(indir):
for z in filenames:
x = urlparse.urljoin('https://berlin.kauperts.de/Strassen/', z+'/'),
[t[0] for t in x],
print(t),
for r in requests.get(t):
print(r),
I get: https://berlin.kauperts.de/Strassen/Igelsteig-12557-Berlin/ <!DOCTYPE html> <html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
How can I make requests.get() return <Response [200]>
instead of just the doctype information? 我得到:
https://berlin.kauperts.de/Strassen/Igelsteig-12557-Berlin/ <!DOCTYPE html> <html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
: https://berlin.kauperts.de/Strassen/Igelsteig-12557-Berlin/ <!DOCTYPE html> <html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
如何使request.get()返回<Response [200]>
而不是仅仅返回文档类型信息?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.