2
您好我使用此代碼從timeanddate.com網站獲取數據。但我需要使用我的用戶名和密碼&在我的牆上抓住評論並將其寫入文本文件,以此來執行我的facebook會話。我可以用python來做這個嗎?怎麼做?如何使用網站使用用戶名和密碼的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
感謝....
使用Facebook的API API而不是 –
是的,你可以在Python中做到這一點。我通常使用''requests''模塊和''BeautifulSoup''進行屏幕抓取。到目前爲止,我從來沒有使用過認證,但如果「請求」不夠用,你總是可以模擬一個瀏覽器,例如使用''mechanize'',或者如上所述使用API。 –
與臉譜和喜歡,我不會試圖screenscrape什麼http://www.zdnet.com/plaxo-screen-scraper-tool-offends-facebook-1339284842/ –