-
714 votesanswersviews
如何使用Python通过HTTP下载文件?
我有一个小工具,用于按计划从网站下载MP3,然后构建/更新播客XML文件,我显然已将其添加到iTunes . 创建/更新XML文件的文本处理是用Python编写的 . 我在Windows .bat 文件中使用wget来下载实际的MP3 . 我宁愿用Python编写整个实用程序 . 我努力寻找一种方法来实际下载Python中的文件,因此我采用了 wget . 那么,我如何使用Python下载文件... -
2 votesanswersviews
获取请求strava v3 api python的活动
编辑 - 因为我无法't tag this with Strava here are the docs if you'感兴趣 - http://strava.github.io/api/ 我完成了身份验证,并在response.read中获取了access_token(以及我的运动员信息) . 我在下一步遇到问题:我想返回有关特定活动的信息 . import urllib2 import... -
3 votesanswersviews
在Python3中使用Urllib下载文件,给予HTTP错误403伪造用户代理?
我正在使用phantomJS和selenium使用anything2mp3.com将Youtube视频转换为mp3,然后尝试下载文件 . 我正在尝试使用Python 3中的 urllib 来下载.mp3文件 . 但是,当我尝试: url = 'example.com' fileName = 'testFile.mp3' urllib.request.urlretrieve(url, fileNam... -
8 votesanswersviews
使用python urllib从url下载映像但接收HTTP错误403:禁止
我想使用python模块“urllib.request”从网址下载图像文件,该模块适用于某些网站(例如mangastream.com),但不适用于另一个(mangadoom.co)接收错误“HTTP错误403:禁止” . 后一种情况可能会出现什么问题以及如何解决? 我在OSX上使用python3.4 . import urllib.request # does not work img_url... -
-2 votesanswersviews
看似“垃圾”的结果与请求
我有this网页 . 当我尝试使用 requests 模块获取其html时: import requests link = "https://www.worldmarktheclub.com/resorts/7m/" f = requests.get(link) print(f.text) 我得到这样的结果: <!DOCTYPE html> <html&g... -
33 votesanswersviews
如何在python中下载任何(!)网页和正确的字符集?
问题 When screen-scraping a webpage using python one has to know the character encoding of the page. 如果你得到的字符编码错误,你的输出就会搞砸了 . 人们通常使用一些基本技术来检测编码 . 它们使用标头中的字符集或元标记中定义的字符集,或者使用encoding detector(它不关心元标记或 He... -
565 votesanswersviews
urllib,urllib2和requests模块之间有什么区别?
在Python中, urllib , urllib2 和requests模块之间有什么区别?为什么有三个?他们似乎做同样的事情...... -
74 votesanswersviews
UnicodeEncodeError:'charmap' codec无法编码字符
我正试图刮一个网站,但它给了我一个错误 . 我正在使用以下代码: import urllib.request from bs4 import BeautifulSoup get = urllib.request.urlopen("https://www.website.com/") html = get.read() soup = BeautifulSoup(html) ... -
2 votesanswersviews
使用Python刮擦多个页面仅重复第一页
我正在试图 grab 这个页面https://www.anesishome.gr/%CE%B2%CF%81%CE%B5%CF%86%CE%B9%CE%BA%CE%AC-159#!/我需要前5页每个产品的名称和价格 . 问题是我的代码给出了第一页的结果5次 . 好像我没有改变下一页的网址 . 我究竟做错了什么?谢谢! from urllib.request import urlopen from b... -
0 votesanswersviews
使用BeautifulSoup的“TypeError:期望的字符串或缓冲区”
我对Python和Beautifulsoup比较陌生 . 我需要简单地解析我正在使用urllib2(用于请求和响应)和BeautifulSoup4进行解析的特定请求的响应 . 我以前使用过这些没有任何问题 . 但是,对于这个特定的项目,我很奇怪地得到错误 . 下面是我编写的代码的一部分: class WebLogin(object): def __init__(self, username, pa... -
0 votesanswersviews
如何移植使用Beautiful Soup 4的python urllib2 app(一个web scraper)来代替使用请求包
我正在尝试更新在Anaconda中使用Python 3中的Beautiful Soup 4的web scraper应用程序来使用Requests包而不是urllib,urllib2和urllib3 . urllib和urllib2在Anaconda Channels 中不存在,并且从我读过的请求包已经使urllib和urllib2过时了 . 我仍然是用于Web抓取的Python编程的新手,并且尚未... -
0 votesanswersviews
Python使用alernating变量下载图像
我试图下载带有url的图像,但是发生了错误 . url_image="http://www.joblo.com/timthumb.php?src=/posters/images/full/"+str(title_2)+"-poster1.jpg&h=333&w=225" user_agent = 'Mozilla/5.0 (Windows ... -
0 votesanswersviews
在Python 2.7中使用URLLIB时出错
从bs4导入urllib导入BeautifulSoup导入重新 sumt = 0 html = urllib.urlopen('http://python-data.dr-chuck.net/comments_338391.html') . read() 汤= BeautifulSoup(html) tags = soup('span') for lne in tags:lne = str(lne... -
192 votesanswersviews
如何发送POST请求?
我在网上找到了这个脚本: import httplib, urllib params = urllib.urlencode({'number': 12524, 'type': 'issue', 'action': 'show'}) headers = {"Content-type": "application/x-www-form-urlencoded", ... -
0 votesanswersviews
使用Python和BS4循环刮擦多个页面
我是一名学生记者,也是蟒蛇新手 . 我一直在试图弄清楚如何使用for循环在我大学每日犯罪日志的所有当前页面上删除每个单独的犯罪日志 . 但是,它只是抓第一页 . 我一直在寻找其他人的代码和问题,但无法弄清楚我错过了什么 . 任何帮助表示赞赏谢谢 . import urllib.request import requests import csv import bs4 import nump... -
0 votesanswersviews
将下载的图像保存在django ImageField中
我想下载一张图片并保存为django ImageField . 我的错误在哪里? from django.core.files import File from urllib.requests import urlretrieve from .models import Photo r = urlretrieve("http://test.com/img/test.png"... -
2 votesanswersviews
Python 3.5 urllib.request 403 Forbidden Error
import urllib.request import urllib from bs4 import BeautifulSoup url = "https://www.brightscope.com/ratings" page = urllib.request.urlopen(url) soup = BeautifulSoup(page, "html.parse... -
0 votesanswersviews
如何使用instagram API通过hashtag获取所有图像?
我试图使用特定的主题标签来获取所有图像,例如egipt . 我的好意思是 https://api.instagram.com/v1/tags/egipt/media/recent?access_token= 不同的组合也是如此 . 我没有获取任何数据或获取空数据或deprecation_warning“此 endpoints 不推荐使用next_max_id和min_id;请改用min_tag_i...