.gitignore + safety header
This commit is contained in:
parent
33cf0cf461
commit
ac23c63ae5
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
env/
|
4
main.py
4
main.py
@ -27,6 +27,8 @@ async def main():
|
||||
async def fetch_station(station: str, session: aiohttp.ClientSession, trains: list) -> None:
|
||||
train_list = []
|
||||
url = "http://www.belgianrail.be/jp/nmbs-realtime/stboard.exe/en"
|
||||
url_header = {'User-Agent': 'python script to fetch trains of belgium. (d.tonitch@gmail.com - in case it is a problem)',
|
||||
'From': 'd.tonitch@gmail.com'}
|
||||
url_data = {
|
||||
'realtime': 'Show', # Dunno
|
||||
'sqQueryPageDisplayed': 'yes', # Dunno
|
||||
@ -43,7 +45,7 @@ async def fetch_station(station: str, session: aiohttp.ClientSession, trains: li
|
||||
'start': 'Show' # Dunno
|
||||
}
|
||||
try:
|
||||
async with session.post(url, data=url_data) as resp:
|
||||
async with session.post(url, data=url_data, headers=url_header) as resp:
|
||||
if resp.status == 200:
|
||||
print(f"station {station} success ✅")
|
||||
soup = BeautifulSoup(await resp.text(), 'html.parser')
|
||||
|
Loading…
Reference in New Issue
Block a user