I'm new to web scraping and ran into a small road block with the following code:
import requests
from bs4 import BeautifulSoup
url = "www.website.com"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
price_scripts = soup.find_all('script')[23]
print(price_scripts)
The scripts that are pulled all appear to be Python scripts. Here's what's printed from the above code:
<script>
p.a = [0,"6.93","9.34","3.42","7.88"];
p.output();
</script>
What I'm trying to do is pull the list from this script, but when I attempt it just returns "None".
print(price_scripts)is doing so or? There isn't enough information here. What are the contents ofsoup.find_all('script')[23]? Can you provide some form of output for what is being stored inprice_scripts? Also, in HTML, these are not Python but are Javascript. If the<script>output is what your output is from print, what are you doing that is returning "None" when attempting to grab the list?