股票爬虫实例程序

时间:2021-08-30 10:07:31
【文件属性】:

文件名称:股票爬虫实例程序

文件大小:2KB

文件格式:PY

更新时间:2021-08-30 10:07:31

python

import requests from bs4 import BeautifulSoup import bs4 def getHTMLText(url): try: r = requests.get(url,timeout=30) r.raise_for_status() r.encoding=r.apparent_encoding return r.text except: return "error" def fillUnivList(ulist,html): soup=BeautifulSoup(html,"html.parser") for tr in soup.find('tbody').children: if isinstance(tr,bs4.element.Tag): tds = tr('td') ulist.append(【tds[0】.string,tds[1].string,tds[3].string])


网友评论