Hi all!
I’ve got a basic scraper using beautiful soup that I’ve been using but I don’t have access to my normal PC currently and would like to still run it on my laptop without any installation, which lead me to finding PyScript which is a cool idea. My python knowledge is basically non-existent - I wrote the original script a while ago just by piecing together info on google.
Anyway I’m trying to run it in PyScript and it seems to run OK, no error messages or anything but I also don’t get any output. Not sure what is going wrong. Any help would be greatly appreciated!!
async function main () {
let pyodide = await loadPyodide();
await pyodide.loadPackage("micropip");
const micropip = pyodide.pyimport("micropip");
await micropip.install('beautifulsoup4');
await pyodide.runPython(`
from bs4 import BeautifulSoup
import requests
for x in range(1,15):
url = "https://basketball.fantasysports.yahoo.com/nba/34548/"+str(x)+"/"
req = requests.get(url)
soup = BeautifulSoup(req.text, "html.parser")
player_text=soup.find_all("a",{"class":"Nowrap name F-link playernote"})
for i in player_text:
print(str(x)+"-"+i.string)
`);
}
main();
Many thanks!