#๐Ÿ”’ Web Scraping Beginner Issues (on Replit)

6 messages ยท Page 1 of 1 (latest)

sick finch
#

im New to web scraping and im encountering this issue for the past 14 days can anyone help?

CODE

`~~from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
import time as tm

URL = "https://www.ndtv.com/fuel-prices/petrol-price-in-coimbatore-city"

chromedriver_path = 'chromedriver_linux64/chromedriver'

date = tm.strftime("%b %d, %Y")

def get_daily_petrol_price():
try:
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")

    service = Service(executable_path=chromedriver_path)
    driver = webdriver.Chrome(service=service, options=options)

    driver.get(URL)


    price_element = WebDriverWait(driver, 20).until(
        EC.presence_of_element_located(
            (By.XPATH, "//div[contains(@class, 'price-box')]//span[contains(@class, 'price-value')]")))

    petrol_price = price_element.text.strip()

    driver.quit()  
    return float(petrol_price.split(" ")[0])

except Exception as e:
    print(f"Error: {e}")
    return None

daily_price = get_daily_petrol_price()
if daily_price:
print(f"Today's Petrol Price: {daily_price}")
else:
print("Failed to fetch the petrol price.")~~`

jolly citrusBOT
#

@sick finch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

slim flax
jolly citrusBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

jolly citrusBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.