您好,我正在使用这段代码从 timeanddate.com 中获取数据地点。但我需要使用我的用户名和密码为我的 Facebook 帐户做同样的事情,并抓取我墙上的评论并将其写入文本文件。我可以用 python 做到这一点吗?如何做到这一点?
import urllib2
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen('http://www.timeanddate.com/worldclock/astronomy.html?n=78').read())
for row in soup('table', {'class' : 'spad'})[0].tbody('tr'):
tds = row('td')
print tds[0].string, tds[1].string
谢谢....
最佳答案
使用Requests API .它还处理身份验证。
关于python - 如何使用网站的用户名和密码在 Python 中使用网络抓取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13195269/