目录
创建类
class info_Spider(object):
def _init_(self,code,Lstr1,Lstr2,idx1,idx2):
self.code = code
self.Lstr1 = Lstr1
self.Lstr2 = Lstr2
self.idx1 = idx1
self.idx2 = idx2
#获取指定范围的数据块
def get_info(self,code):
self.code = code
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_driver = 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe'
#chromedriver的文件位置
#
driver = webdriver.Chrome(executable_path = chrome_driver,chrome_options=chrome_options)
url = 'http://fund.eastmoney.com/pingzhongdata/' + code + '.js?v=20190304115823'
driver.get(url)
#检查网页发现数据以json格式 存放在pre标签中 使用x_path匹配标签匹配数据
getPage_text = driver.find_element_by_xpath(\
"//pre"
Python实现抓取并处理场内基金数据

本文介绍了一个使用Python编写的`info_Spider`类,该类通过Chrome浏览器驱动抓取东方财经网站的场内基金数据,并进行处理。数据首先被存储到临时文件,然后转化为SQL语句插入到MySQL数据库中。然而,文章指出该方法存在三个问题:1) 大数据量可能导致list溢出;2) 批量SQL语句末尾的逗号需要替换为分号;3) 欢迎读者提供解决方案。
最低0.47元/天 解锁文章

1584

被折叠的 条评论
为什么被折叠?



