(Apr-04-2019, 07:26 AM)yimchiwai Wrote: Brother ,how to get vsl name all txt file
import requests
from bs4 import BeautifulSoup
import datetime
url="https://cplus.hit.com.hk/enquiry/vesselScheduleEnquiryAction.do"
ETBFrom=datetime.date.today().strftime("%d-%m-%Y")
ETBTo='11-05-2019'
query='%E6%90%9C%E7%B4%A2'
vesselName=["WAN+HAI+272","WAN+HAI+172","WAN+HAI+171"]
for vslcount in vesselName:
with open(f'{vslcount}.txt', 'w', encoding='utf-8') as f_out:
#print(vslcount)
new_url = f'{url}?vesselName={vslcount}&ETBFrom={ETBFrom}&ETBTo={ETBTo}&query={query}'
response = requests.get(new_url)
soup = BeautifulSoup(response.content, 'html.parser')
vessel = soup.find_all('td', class_="body")[1]
record=[]
for item in vessel.find_all('td')[6:-3]:
record.append(item.text.strip())
new_record = []
for i in range(0,len(record),6):
new_record.append(record[i:i+6])
print(new_record[0:2])
f_out.write(f'{new_record[0:2]}')
(Apr-04-2019, 12:04 PM)yimchiwai Wrote: Final i want check my data compare with the web
You have to try to do something