Friends i want to extract live scores on espncricinfo i try with dryscrape :-
Import dryscrape as d
d.start_xvfb()
br = d.Session()
br.visit('http://www.espncricinfo.com/ci/engine/match/index.html?view=live')
for x in br.xpath('//*[@class = "innings-info-1"]'):
x
#print 4 results
for y in br.xpath('//*[@class = "innings-info-2"]'):
y
#print 4 results of 2nd innings
#but when i try combian then print tooo many results
for x in br.xpath('//*[@class = "innings-info-1"]'):
for y in br.xpath('//*[@class = "innings-info-2"]'):
x,'\n',y
#need 4+4=8 results but python prints 16 results
Please help me
You have double loop. First have 4 elements, second 4 element. So you iterate 4 times by second loop and get 4 + 4 + 4 + 4 = 16. Your code execute the way it should.
if you want to get list of result you can for example do it like this:
x = [x for x in br.xpath('//*[@class = "innings-info-1"]')]
y = [y for y in br.xpath('//*[@class = "innings-info-2"]')]
print(list(zip(x,y))