Created
December 30, 2020 23:00
-
-
Save aladagemre/da4bdafec53aad01d081056fbe42d604 to your computer and use it in GitHub Desktop.
N11 kategori listesini çeken bir script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bs4 | |
import csv | |
import requests | |
r = requests.get("https://www.n11.com/site-haritasi") | |
soup = bs4.BeautifulSoup(r.text, features="html.parser") | |
with open("kategoriler.csv", "w") as csvfile: | |
writer = csv.writer(csvfile, delimiter=';', quotechar='"') | |
mcs = [(a.text, a.get('href')) for a in soup.find_all("a", class_="main-category")] | |
writer.writerow(["Kategori", "Adres"]) | |
for cat in mcs: | |
writer.writerow(list(cat)) | |
with open("altkategoriler.csv", "w") as csvfile: | |
writer = csv.writer(csvfile, delimiter=';', quotechar='"') | |
mcs = [(div.a.text, div.a.get('href')) for div in soup.find_all("div", class_="sub-category")] | |
writer.writerow(["Kategori", "Adres"]) | |
for cat in mcs: | |
writer.writerow(list(cat)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment