My app is supposed to collect flight data and parse it in a quick and efficient manner. When running it locally, the project returns pricing data. However, when running in the cloud, it instantly fails to collect the data, displaying an error that I have programmed in. Does bs4 have known issues with Cloud?
Any assistance would be greatly appreciated.
Thanks!
Attatched, please find a link to the github repository, as well as the cloud based app:
Github Project
Streamlit App
EDIT/ UPDATE:
I have narrowed down the problem to requests.get recieving different data when running in Streamlit Cloud. Not entirely sure why, but I can reproduce the issue in Brave while in incognito, while Edge incognito still retrieves the correct data. The program also works on Replit… Are there any ways to diagnose the potential issue with the request, as well as any way to mimic my local setup?
For reference, here is the relevant code, as well as screenshots of Edge vs Brave (both have JS disabled; trying to extract the table data using the relevant tags):
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
browser = requests.get(f'https://www.google.com/search?q=fly{airline}+from+{origins}+to+{destination}+on+{date}+one+way{nonstop}', headers = headers)
soup = BeautifulSoup(browser.content, 'html.parser')
airlinefind = soup.find_all(class_='BNeawe s3v9rd AP7Wnd')
for air in airlinefind:
if airlinefind[x].string != None and airlinefind[x].string != 'Southwest':
if len(airlinefind[x].string) > 19:
st.write(f"Broke at 112; {airlinefind[x].string}, position {x} :thumbsdown:")
break
airlines.append(airlinefind[x].string)
st.write(f"{airlinefind[x].string} :thumbsup:")
x+=1
for air in airlines:
if " " in air and air not in airlinelist:
st.write(f"{air} 😠")
pass
else:
new.append(air)
st.write(f"{air} :airplane:")
Edge incognito
Brave incognito