0

What do the numbers signify in this result, and why doesn't a list of the data I would expect print in this situation?

"generator object grab_listings at 0x10220f640"

import requests
from bs4 import BeautifulSoup
import csv


def grab_listings():
    for i in range(0, 5):
        url = "http://www.gym-directory.com/listing-category/gyms-fitness-centres/page/{}/"

        r = requests.get(url.format(i + 1))
        soup = BeautifulSoup(r.text, 'html.parser')
        l_area = soup.find("div", {"class": "wlt_search_results"})

        for elem in l_area.findAll("a", {"class": "frame"}):
            yield elem["href"]

l = grab_listings()
print l
DanielSon
  • 1,415
  • 4
  • 27
  • 40
  • 1
    `l = list(grab_listings())`, you have created a generator so you see the reference to the generator when you print l, you can call list on it, iterate over it or call next on it – Padraic Cunningham Sep 28 '15 at 14:45
  • 1
    Given [your previous question](http://stackoverflow.com/q/32820713/3001761), note that `for row in l:` **will still work** - that's the whole point of switching to a generator. Consider reading the tutorial: https://docs.python.org/3/tutorial/classes.html#generators – jonrsharpe Sep 28 '15 at 14:47
  • 1
    Thanks Padraic. Will go over existing question as well jonrsharpe - time for some more study – DanielSon Sep 28 '15 at 14:47

0 Answers0