update,
This commit is contained in:
51
hkfatimah/bf_helloworld_old.py
Normal file
51
hkfatimah/bf_helloworld_old.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os,sys
|
||||
from pprint import pprint
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
|
||||
main_url = "https://www.mchk.org.hk/english/list_register/list.php?page=4&ipp=20&type=L"
|
||||
req = requests.get(main_url)
|
||||
soup = BeautifulSoup(req.text, "html.parser")
|
||||
|
||||
title = soup.find("h1")
|
||||
# print(title.get_text())
|
||||
|
||||
trs = soup.select("table#Table_5 table tr")
|
||||
for tr in trs[2:]:
|
||||
try:
|
||||
# name
|
||||
tds = tr.select('td[headers="reg"]')
|
||||
if (len(tds) > 0):
|
||||
# reg field got something
|
||||
print(tds[0].get_text())
|
||||
|
||||
# # name
|
||||
tds = tr.select('td[headers="name"]')
|
||||
print(tds[0].get_text())
|
||||
|
||||
# # qualification
|
||||
tds = tr.select('td[headers="qualification"]')
|
||||
print(tds[0].get_text())
|
||||
print(tds[1].get_text())
|
||||
pass
|
||||
else:
|
||||
# reg field got nothing
|
||||
|
||||
pass
|
||||
except Exception as e:
|
||||
print(tr)
|
||||
print(e)
|
||||
print('error')
|
||||
pass
|
||||
# tds = tr.select('td')
|
||||
# pprint(tds)
|
||||
# print()
|
||||
# print()
|
||||
# print()
|
||||
# break
|
||||
# # print(tds)
|
||||
|
||||
# pprint('helloworld')
|
||||
|
Reference in New Issue
Block a user