想請問code沒問題下
出現 HTTP Error 500: server error
這樣狀況是什麼問題?
爬的網頁可以開啟
用本地IP去爬也是出現這個error
也排除IP問題
想請問有什麼解決法?
code片段如下 抓的是奇摩股票新聞
stockList = [line.rstrip() for line in open('test1.txt')]
for count in range(100000000):
t1 = time.time()
timeCount = 0
for stockNum in stockList:
d = feedparser.parse('http://tw.stock.yahoo.com/rss/s/%s' % stockNum)
lens = len(d.entries)
print lens
for newsNum in range(lens):
print d.feed.title
title = d.entries[newsNum].title.encode('utf-8')
print title
rTitle = title.replace('/', '.')
link = d.entries[newsNum].link
req = urllib2.Request(link)
print req.__doc__
if not req.__doc__:
continue
content = urllib2.urlopen(req).read()
save = open('./database/%s/%s.news' % (stockNum, rTitle), 'w')
save.write(content)
save.close()