External links
Official website
Category:Physics textbooks
Category:Scientific modelingQ:
Separating HTML data with slashes
I'm having a little trouble separating the string from the data
string = '5 in 1 H '
I want to have
['5', 'in', '1'], [' ', 'H ']
But at the moment I'm getting this:
['5', 'in', '1', 'H ']
Code for getting string:
for url in ['', '']
html = requests.get(url)
soup = BeautifulSoup(html.text)
string = soup.findAll('a', attrs={'href':''})[0]['href']
A:
I used a regular expression to take out the parts I needed from the string. Thanks for the help
regex_to_parse = re.compile(r'(?i)href=["']?([^"']*)')
def parse_links(data):
links = []
for match in regex_to_parse.finditer(data):
links.append(match.group(1))
return links
def main():
url = ''
links = parse_links(url)
for link in links:
print link
if __name__ == '__main__':
main()
OUTPUT:
5-in-1
5-in-1-h
You can put it in a loop and apply it to all the links if you need.
A Christmas present with a wow factor
This Christmas, I am sure you will want to give the whole family something extra special, a gift that will wow them. We have taken this advice from our precious angel to heart and created a beautiful gift for my husband and I, ac619d1d87
Related links:
Comments