Skip to content

Commit

Permalink
#update crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Oct 1, 2018
1 parent e387fed commit 9aa2cb3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
8 changes: 4 additions & 4 deletions QUANTAXIS/QACmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def do_save(self, arg):
QA_SU_save_stock_list('tdx')
QA_SU_save_stock_block('tdx')
# QA_SU_save_stock_info('tdx')
QA_SU_save_report_calendar_his()
QA_SU_save_stock_divyield_his()
# QA_SU_save_report_calendar_his()
# QA_SU_save_stock_divyield_his()

elif len(arg) == 1 and arg[0] == 'day':
if QA_Setting().client.quantaxis.user_list.find({'username': 'admin'}).count() == 0:
Expand All @@ -251,8 +251,8 @@ def do_save(self, arg):
QA_SU_save_index_list('tdx')
QA_SU_save_stock_list('tdx')
QA_SU_save_stock_block('tdx')
QA_SU_save_stock_divyield_day()
QA_SU_save_report_calendar_day()
# QA_SU_save_stock_divyield_day()
# QA_SU_save_report_calendar_day()

elif len(arg) == 1 and arg[0] == 'min':
if QA_Setting().client.quantaxis.user_list.find({'username': 'admin'}).count() == 0:
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/QAWeb/backtesthandles.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


class BacktestHandler(QAWebSocketHandler):

client={}
def open(self):
self.client.add(self)
Expand Down
39 changes: 39 additions & 0 deletions QUANTAXIS_CRAWLY/gecko_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import time

import pandas as pd
from selenium import webdriver

"""这里我给了一个同花顺的页面爬虫 用于gecko_driver 也就是 火狐浏览器内核爬虫的教学
推荐使用火狐浏览器的内核 配置方便
"""

opener = webdriver.Firefox() # should make sure the gekkodriver.exe in path
data = []


for item in ['gn', 'dy', 'thshy', 'zjhhy']:
opener.get('http://q.10jqka.com.cn/{}/'.format(item))

hpage = opener.page_source

# opener.save_screenshot('page_gn.png')
try:
if opener.find_element_by_class_name('cate_toggle.boxShadow').text == '收起':
pass
else:
opener.find_element_by_class_name('cate_toggle.boxShadow').click()
except:
pass

res = opener.find_elements_by_xpath('/html/body/div/div/div/div/div/a')

data.extend([[res.text, res.get_attribute('href'), item] for res in res])

time.sleep(1)


res = pd.DataFrame(data)
print(res)
opener.close()
res.to_csv('ths.csv')
4 changes: 2 additions & 2 deletions config/update_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
QA_SU_save_stock_list('tdx')
QA_SU_save_stock_block('tdx')
QA_SU_save_stock_info('tdx')
QA_SU_save_stock_divyield_day()
QA_SU_save_report_calendar_day()
# QA_SU_save_stock_divyield_day()
# QA_SU_save_report_calendar_day()

0 comments on commit 9aa2cb3

Please sign in to comment.