Home > Blockchain >  How to exclude last line from scraped content in python selenium
How to exclude last line from scraped content in python selenium

Time:05-13

content = driver.find_elements(By.XPATH,'//div[@id="content"]/p')

Now there is a list of paragraphs that were scraped, like- content[0],content[1].....content[9] The number of paragraph is not fixed everytime, I want to delete the last paragraph from the content.

CodePudding user response:

Try to explain exactly what you want, and what you get. So edit you question with more details. Let us help you...

CodePudding user response:

You could use slicing:

content = driver.find_elements(By.XPATH,'//div[@id="content"]/p')[:-1]
  • Related