Reputation: 123
I am trying to do some web scraping and I came across this problem: I wanna take a tag that's called <name>
but name is also a keyword in python so when I try to take that tag with the code below:
entries_map = []
for entry in entries:
entry_title = entry.title.text
entry_author = entry.name
entries_map.append(entry_author)
entries_map.append(entry_title)
print(entries_map)
I get this: ['entry', "Some title I scraped", 'entry', "Some title I scraped", ...]
So how can I take that tag?
Upvotes: 0
Views: 52
Reputation: 781716
You can use the .find()
method to search for a child element with a specific tag.
entry_author = entry.find('name').text
Upvotes: 1