[問題] 爬蟲出現問題
想請問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()
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.15.146.112
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1464065502.A.5CB.html
→
05/24 13:16, , 1F
05/24 13:16, 1F
有找過才上來問,很多是說設定網際網路選項 http錯誤訊息,但我是用Mac.. 原本抓好
好突然出現這問題@@
※ 編輯: proud (101.15.146.39), 05/24/2016 13:41:32
→
05/24 16:59, , 2F
05/24 16:59, 2F
推
05/24 17:09, , 3F
05/24 17:09, 3F
→
05/24 17:09, , 4F
05/24 17:09, 4F
→
05/24 20:04, , 5F
05/24 20:04, 5F
請問terminal要怎處理?
※ 編輯: proud (111.240.33.176), 05/24/2016 22:17:10
我curl -v 一下 connection : close
※ 編輯: proud (111.240.33.176), 05/24/2016 22:21:03
→
05/25 13:18, , 6F
05/25 13:18, 6F
※ 編輯: proud (111.240.30.76), 05/25/2016 21:52:26
寫的不好還請指教,github不太好意思。手機看會失真
※ 編輯: proud (49.214.149.138), 05/25/2016 22:01:35
推
05/25 22:43, , 7F
05/25 22:43, 7F
→
05/25 22:48, , 8F
05/25 22:48, 8F
→
05/25 22:48, , 9F
05/25 22:48, 9F
謝謝aweimeow!
推
05/26 08:54, , 10F
05/26 08:54, 10F
→
05/27 11:37, , 11F
05/27 11:37, 11F
→
05/27 22:13, , 12F
05/27 22:13, 12F
→
05/27 22:15, , 13F
05/27 22:15, 13F
※ 編輯: proud (101.12.147.62), 05/30/2016 19:38:06