In my script below if I take out "return" statement and place there "print" then I get all the results. However, If i run it as it is, i get only the first item. My question is how I can get all the results using "return" in this case, I meant, what should be the process?
Here is the script:
import requests
from lxml import html
main_link = "http://onlinelibrary.wiley.com/journal/10.1111/(ISSN)1467-6281/issues"
def abacus_scraper(main_link):
tree = html.fromstring(requests.get(main_link).text)
for titles in tree.cssselect("a.issuesInYear"):
title = titles.cssselect("span")[0].text
title_link = titles.attrib['href']
return title, title_link
print(abacus_scraper(main_link))
Result:
('2017 - Volume 53 Abacus', '/journal/10.1111/(ISSN)1467-6281/issues?activeYear=2017')