how can i get the link in the href tags? How i coded it appears the whole 'a' tag... Code:
page = urllib2.urlopen('https://www.meetup.com/')
soup = BeautifulSoup(page, 'lxml')
categories = soup.find('ul', class_='gridList')
A = []
B = []
for category in categories.findAll('li'):
text = category.findAll('h4')
if len(text) != 0:
A.append(text[0].find(text = True))
for link in categories.findAll('li'):
url = link.findAll('a', href=True)
if len(url) != 0:
B.append(url)
...
(your code above)
for link in categories.findAll('li'):
url = link.find('a', href=True)
if len(url) != 0:
B.append(url['href'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.