scraper.py

 avatar
unknown
python
4 years ago
754 B
4
Indexable
#scraper.py

from bs4 import BeautifulSoup
import urllib.request

url2 = "https://sfatulparintilor.ro/bebelusi/semnificatii-nume/nume-de-fete-semnificatie-nume-cum-sa-alegi-cel-mai-potrivit-nume-pentru-fetita-ta-ai-peste-1000-de-variante/";


open('output.txt', 'w').close()

for i in range(1, 6):
    html = urllib.request.urlopen(url2 + str(i) + "/")

    htmlParse = BeautifulSoup(html, 'html.parser')

    with open('output.txt', 'a') as file:
        for name in htmlParse.select(".single_body_left p strong"):
            string = name.get_text()
            if "Citeste continuarea pe pagina urmatoare:" not in string and "“" not in string and string != "" and string != " ":
                file.write(name.get_text() + "\n")
Editor is loading...