-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ | |
|
||
|
||
class BacktestHandler(QAWebSocketHandler): | ||
|
||
client={} | ||
def open(self): | ||
self.client.add(self) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters