Giúp lấy data realtime



  • import time
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys

    driver = webdriver.Chrome()
    driver.get("http://batdongsan.com.vn")

    time.sleep(5)

    rows = len(driver.find_elements_by_xpath('//*[@id="ctl31_BodyContainer"]/div/div'))

    print(rows)

    for r in range (1,rows) :

    val = driver.find_element_by_xpath('//div[@id="ctl31_BodyContainer"]/div/div['+str(r)+']/div/div/div/h3/a[@id="ctl31_ctl00_rpListProduct_lnkTitle_'+str(r-1)+'"]').text
    
    if val:
    	print(val)
    else:
    	print(r)
    

    print()

    Hướng dẫn giùm mình làm sao để mỗi lần có tin mới, nó tự lấy về luôn, không cần chạy lại , Cám ơn


Log in to reply
 

Looks like your connection to Cộng đồng Python Việt Nam was lost, please wait while we try to reconnect.