[Python] regex returns more data than it should

Discussão em 'Python' iniciado por Stack, Novembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    please read before you comment. im trying to make a simple website scraper but i run into this error, it scrapes urls for scripts and its apparently capturing :

    SCRIPT URL : https://accounts.google.com/ServiceLogin?service=youtube&uilel=3&passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26app%3Ddesktop%26hl%3Den-GB%26next%3D%252Fsignin_passive%26feature%3Dpassive&hl=en-GB" style="display: none"><input id="search"... etc

    using this script:

    import re
    import requests
    sitemap = requests.get("https://youtube.com").text
    javascriptmatches = re.findall("src=\"(https?://.*?\.js)\??.*?\"",sitemap)
    for x in javascriptmatches:
    print(x)


    update: i'm using the built in "re" library.

    Continue reading...

Compartilhe esta Página