Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ua = UserAgent()
- user_agent = {'User-agent': ua.random} #changement d'user-agent (random)
- url = "https://www.leboncoin.fr/locations/offres/ile_de_france/hauts_de_seine/?th=" + page + "&mre=" + prix_max + "&sqe=" + surface + "&ret=2&furn=" + m
- req = requests.get(url, headers=user_agent)
- stat = req.status_code
- if stat == 200:
- if "Urgentes" not in req.text:
- print "URL not found"
- break
- else:
- print "\033[42m URL found \033[0m"
- print "*" * 15
- if "Aucune" in req.text: #si aucune annonce trouver
- print "Aucune annonce trouve"
- print "*" * 15
- break
- else:
- soup = BeautifulSoup(req.text,"html.parser")
- resultats = soup.find('section', {"class":"tabsContent block-white dontSwitch"})
- annonces = resultats.find_all("li")
- for annonce in annonces:
- tag_a = annonce.find("a")
- lien_annonce = tag_a.get("href")
- title = annonce.find("h2").text.strip()
- price = annonce.find("h3").find(text=True, recursive=False).strip()
- dte = annonce.find('p', {'itemprop':'availabilityStarts'}).get('content')
- # FILTRE ICI
- print('titre:%s' % title)
- print('price:%s' % price)
- print('date:%s' %dte)
- print('lien:%s' % lien_annonce)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement