[Tutor] Unable to retreive the stock code
Crusier
crusier at gmail.com
Mon Nov 16 02:41:54 EST 2015
Dear All,
I am currently trying to download the stock code. I am using Python
3.4 and the code is as follows:
from bs4 import BeautifulSoup
import requests
import re
url = 'https://www.hkex.com.hk/eng/market/sec_tradinfo/stockcode/eisdeqty.htm'
def web_scraper(url):
response = requests.get(url)
html = response.content
soup = BeautifulSoup(html,"html.parser")
for link in soup.find_all("a"):
stock_code = re.search('/d/d/d/d/d', "00001" )
print(stock_code, '', link.text)
print(link.text)
web_scraper(url)
I am trying to retrieve the stock code from here:
<td class="verd_black12" width="18%">00001</td>
or from a href.
Please kindly inform which library I should use.
Thanks
Henry
More information about the Tutor
mailing list