yeah, i checked the page source and it works just fine; i don't think there's gonna be much variation in there, unless they change the whole layout of the website but in that case it's not just gonna be 1 tag that doesn't match. :D
anyway, now i got the link part, the title part and the ad id part and all i need to do is convert the adid into views.
i'm using the code you guys gave me:
i thought about zipping 2 lists together but it doesn't print out a dictionary and both lists have to be the same length whereas here i'm trying to fit 'add-view' with whatever id i can get in there.
anyway, now i got the link part, the title part and the ad id part and all i need to do is convert the adid into views.
i'm using the code you guys gave me:
# adid is 18238521 # views is 4 href = 'http://www.publi24.ro/anunturi/imobiliare/de-vanzare/apartamente/garsoniera/anunt/Garsoniera-Sector-1/7b006674706c6156.html' def get_adid(item_url): source_code = requests.get(item_url) plain_text = source_code.text soup = BeautifulSoup(plain_text, 'html.parser') for link in soup.findAll('span', {'class':'fa fa-eye'}): adid = link.get('ng-init') num = adid.split('=')[1] print(num) def views(item_url): browser = webdriver.PhantomJS(r'D:\phantomjs-2.1.1-windows\bin\phantomjs.exe') browser.get(item_url) time.sleep(0) soup = BeautifulSoup(browser.page_source, 'html.parser') tag = soup.find('span', {'add-view':get_adid(href)}) print(tag.text) browser.quit()but i'm not sure how to pass the adid from the get_adid() function into the dictionary from the 'tag' variable from the views() function. i tried putting it in there but it just prints the adid instead.
i thought about zipping 2 lists together but it doesn't print out a dictionary and both lists have to be the same length whereas here i'm trying to fit 'add-view' with whatever id i can get in there.