[問題] 新手請益 關於抓資料
各位大神好,小弟上次問了問題卻沒有附上程式碼
還是有前輩願意回答 先謝謝
附上程式碼 以及我想做的事
從 玩股網的這個頁面
抓出*美林這個券商在 股票1101的進出明細
小弟目前做出來的方法
只能跑出 含有<td class="up">+150</td>.....
這樣的結果
想請問要怎麼做才能夠只選出 數字 然後將數字結果全部加總呢??
*電腦排版 手機可能格式會跑掉
在此感謝之前回應過的大神們 但小弟不才 python目前正在學習階段
有請大神們幫幫忙 謝謝
# -*- coding: utf-8 -*-
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.support.ui import Select
import time
driver = webdriver.Chrome()
driver.get('https://www.wantgoo.com/stock/agentsata?types=8')
time.sleep(0.5)
driver.find_element_by_id("broker").click()
Select(driver.find_element_by_id("broker")).select_by_visible_text(u"美林")
time.sleep(0.5)
driver.find_element_by_id("stock").click()
Select(driver.find_element_by_id("stock")).select_by_value('1101') #index(int)
time.sleep(0.5)
driver.find_element_by_id("sendSubmit").click()
time.sleep(0.5)
html = driver.page_source
sp = BeautifulSoup(html,'lxml')
def has_class_but_no_id(tag):
return tag.has_attr('class') and not tag.has_attr('id')
data = sp.find(id = "datalist")
qq = data.find_all(has_class_but_no_id)
print (qq)
driver.close()
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.136.55.209
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1527931728.A.E08.html
→
06/02 18:23,
6年前
, 1F
06/02 18:23, 1F
→
06/02 18:25,
6年前
, 2F
06/02 18:25, 2F
→
06/02 18:26,
6年前
, 3F
06/02 18:26, 3F
→
06/02 18:27,
6年前
, 4F
06/02 18:27, 4F
→
06/02 18:27,
6年前
, 5F
06/02 18:27, 5F
→
06/02 21:25,
6年前
, 6F
06/02 21:25, 6F
→
06/02 21:25,
6年前
, 7F
06/02 21:25, 7F
→
06/02 22:24,
6年前
, 8F
06/02 22:24, 8F
推
06/03 00:48,
6年前
, 9F
06/03 00:48, 9F
→
06/03 11:46,
6年前
, 10F
06/03 11:46, 10F
→
06/03 11:46,
6年前
, 11F
06/03 11:46, 11F
推
06/03 13:41,
6年前
, 12F
06/03 13:41, 12F
→
06/03 13:41,
6年前
, 13F
06/03 13:41, 13F
→
06/03 13:41,
6年前
, 14F
06/03 13:41, 14F
→
06/03 13:55,
6年前
, 15F
06/03 13:55, 15F