parsing - Scraping HTML info with Python -


I want to find product name (product 1) given product ID (product ID 1111111) using Python. To return the status of the productive character, we have to use the function to back up some characters, but I'm sure there is a better way to do this.

HTML code:

  & lt; Html & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; An id = "ProductID1111111" class = "product" href = "some url" & gt; & Lt; Span id = "ProductID1111111" & gt; Product 1 & lt; / Span & gt; & Lt; / A & gt; & Lt; BR & gt; & Lt; An id = "ProductID2222222" class = "product" href = "some url" & gt; & Lt; Span id = "ProductID2222222" & gt; Product 2 & lt; / Span & gt; & Lt; / A & gt; & Lt; / TD & gt; & Lt; TR & gt; & Lt; / Table & gt; & Lt; / Html & gt;  

python:

  from selenium import to selenium. Webdiver.com. Import key key driver = webdriver.firfox () driver.get (' Someurl .com ') html = driver.page_source  

find element and id attribute value:

  span = driver.find_element_by_xpath ('// span [. = "Product1"]) Product_id = Span.get_attribute ('id')  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -