想从一个网站上批量下载文章,现在可以得到文章的名字。但是打开pdf网页后,连接中的空格被替换成了 %20这样的字符。字符替换我自己可以处理,但是有了链接后怎么下载呢?也就是说怎么执行浏览器里save link as这个动作?我如何向服务器发送这种请求并下载这些文章?
%20
save link as
闭关修行中......
urlretrieve(url, filename=None, reporthook=None, data=None)Try this function to download the url locally.
urlretrieve(url, filename=None, reporthook=None, data=None)
%20 means spaces. Can you just process it again?
I checked online and found that solving this problem is quite simple. You can refer to here
Direct
url = 'FILE ADDR' r = requests.get(url) with open('1.pdf', 'wb') as f: f.write(r.content)
urlretrieve(url, filename=None, reporthook=None, data=None)
Try this function to download the url locally.
%20 means spaces.
Can you just process it again?
I checked online and found that solving this problem is quite simple.
You can refer to here
Direct