Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def parser(url:str):
- try:
- res=requests.get(url=url)
- soup=BS(res.text,"html.parser")
- products=soup.findAll("div",{"class":"item_block"})
- for product in products:
- name=product.find("div",{"class":"item-title"}).text
- price=product.find("span",{"class":"price_value"}).text
- brand=product.find("div", {"class":"article_block"}).text
- la=re.sub(r'\s+', '', brand, flags=re.UNICODE).replace("Артикул:","")
- name1=re.sub(r'\s+', '', name, flags=re.UNICODE)
- arro=(re.sub(r'\s+', '', price, flags=re.UNICODE)+"rub")
- beign=[name,arro,la]
- print(f"{name1}{arro}{la}")
- f = open("text.txt", "a", encoding="utf-8")
- f.write("".join(beign))
- f.close
- except AttributeError:
- print("none")
- a=int(input("введите число(от)"))
- b=int(input("введите число(до)"))
- for z in range(a,b):
- parser(f"https://beorganic.ru/catalog/kosmetika/?PAGEN_1={z}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement