Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
La multi ani @Lotusisrael!

Declarație primar

Contestare amenda politia locala

PC se restarteaza cu erori ecran ...
 Mercedes atego 815 oprire motor

Ce contine Creion rani dupa ras?

Filtru sedimente inainte de pompa?

Paște fericit!
 electrician constructor video curs

Cum pot bloca transferul de date ...

Ce reprezinta in chimie abrevieri...

Google pay ma taxeaza in timp ce ...
 Kia Picanto 2022 - Problema motor?

Durere umar AC Joint

Care este cea mai sanatoasa paine?

Zgomot ritmic ce urmeaza rotirea ...
 

Ajutor! Cum trec prin toate elementele unei liste cu Python si Selenium

- - - - -
  • Please log in to reply
No replies to this topic

#1
thusarix

thusarix

    Junior Member

  • Grup: Members
  • Posts: 136
  • Înscris: 22.04.2007
Incerc sa fac un web scraper in Python cu Selenium, nu stiu eu prea multe in programare dar sunt destul de logic si prind repede. Web scraperul meu incearca sa ia cote de pariuri de pe un site te pariuri.
  Vreau sa verific elementele sa vad innertext si in functie de ce scrie in el sa faca ceva, m-am lovit de urmatoarea problema, codul meu scrie textul din primul element gasit de atatea ori cate elemente sunt, eu vreau sa vad toate textele din elemente:
acesta e loop-ul buclucas:
PlajePariuri = driver.find_elements_by_xpath("//ul[@class='KambiBC-list-view__column']")
for items in PlajePariuri:
   NumePlaje = items.find_element_by_xpath("//li/header/h2")
   print (NumePlaje.text)

si acesta e codul html din care vreau sa extrag textele:
<ul class="KambiBC-list-view__column">
				 <li class="KambiBC-bet-offer-category KambiBC-collapsible-container KambiBC-expanded KambiBC-bet-offer-category--hidden KambiBC-bet-offer-category--fade-in">
				 <header class="KambiBC-bet-offer-category__header" data-touch-feedback="true">
					 <h2 class="KambiBC-bet-offer-category__title js-bet-offer-category-title">Piete selectate</h2>
				 </header>
				 </li>
				 <li class="KambiBC-bet-offer-category KambiBC-collapsible-container KambiBC-expanded KambiBC-bet-offer-category--hidden KambiBC-bet-offer-category--fade-in">
					 <header class="KambiBC-bet-offer-category__header" data-touch-feedback="true">
					 <h2 class="KambiBC-bet-offer-category__title js-bet-offer-category-title">Another text</h2>
					 </header>
				 </li>
				 <li class="KambiBC-bet-offer-category KambiBC-collapsible-container KambiBC-bet-offer-category--hidden KambiBC-bet-offer-category--fade-in">
					 <header class="KambiBC-bet-offer-category__header" data-touch-feedback="true">
					 <h2 class="KambiBC-bet-offer-category__title js-bet-offer-category-title">Different text</h2>
					 </header>
</li>
	
				 <li class="KambiBC-bet-offer-category KambiBC-collapsible-container KambiBC-bet-offer-category--hidden KambiBC-bet-offer-category--fade-in">
					 <header class="KambiBC-bet-offer-category__header" data-touch-feedback="true">
					 <h2 class="KambiBC-bet-offer-category__title js-bet-offer-category-title">Yet another text</h2>
					 </header>
				 </li>
	
</ul>
					
		



daca e nevoie pot pune tot codul python unde se vede si site-ul.

Edited by thusarix, 02 September 2017 - 12:42.


Anunturi

Bun venit pe Forumul Softpedia!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate