I'm having trouble getting a script to work on pythonanywhere even though it works for me locally. I tried some other solutions I found in the forum for people with similar issues, but it's still not working for me...
Background:
- I'm using selenium to scrape values from an ArcGIS dashboard.
- I have confirmed via screenshots and the html output that the local version of my script properly loads the dashboard webpage, but the pythonanywhere version only loads the dashboard text labels and not the numeric values that I need. The HTML headers look identical in both cases. I can't figure out why the whole page doesn't load from my pythonanywhere-based script...
My setup:
- I have the haggis system image.
- I'm running the default version of Python (3.10).
- I have the latest version of selenium (4.26.1 via
pip install --user --upgrade selenium
) - I have a paid account.
- I have tried
time.sleep()
values up to 120 seconds to allow plenty of time for the page to fully load, and this doesn't fix the problem.
Code snippet:
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
browser = webdriver.Chrome(options=chrome_options)
url = "https://townofsuperior.maps.arcgis.com/apps/dashboards/b6f5d5b7137142e7a75d452bff134ebb"
browser.get(url)
time.sleep(30)
html = browser.page_source
labels = browser.find_elements(By.CSS_SELECTOR, 'g.responsive-text-label')
for label in labels:
print(label.text)
print(html)
Output when I run it locally:
Commercial Properties
4
Public Property
1
Residential Properties
393
Permits Issued
307
Certificates of Occupancy
270
Destroyed Properties
398
Debris Removal
Complete
Output when I run it on pythonanywhere;
Commercial Properties
Public Property
Residential Properties
Permits Issued
Certificates of Occupancy
Destroyed Properties
Debris Removal
Complete
Can anyone help me with what the problem might be...?!? Thank you.