@anonymous/

WarpedDistantObjectdatabase

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests as req
import lxml
from bs4 import BeautifulSoup as bs

def get_unidas():
  url = "https://www.seminovosunidas.com.br/veiculos/page:{}?utm_source=afilio&utm_medium=display&utm_campaign=maio&utm_content=ron_ambos&utm_term=120x600_promocaomaio_performance_-_-"
  indice_pagina = 105
  dados = {}
  while True:
    #headers = {'User-Agent':random.choice(user_agent_list)}
    r = req.get(url.format(indice_pagina))
    soup = bs(r.text, "lxml")
    pagina_atual = list(soup.find(class_="active number").stripped_strings)[0]
    print(pagina_atual)
    if indice_pagina >= 2 and pagina_atual == '1': break
    carros = soup.find_all(class_="vehicleDescription")
    valores = soup.find_all(class_="valor")
    for carro, valor in zip(carros,valores):
      texto = list(carro.stripped_strings)
      dados["Empresa"] = "Unidas"
      dados["Modelo"] = texto[2]
      dados["Preco"] = valor.text.replace(".","").replace(",",".")
      dados["Kilometragem"] = texto[4].split(",")[1][5:]
      dados["Ano"] = texto[3][-5:-1]
      #print("#######################################")
    indice_pagina += 1

get_unidas()