(Jan-20-2020, 12:48 PM)jkessous Wrote: How do i get both on the same line that it will be something like this
name - id
There is own id tag in card that get eg
id="989670"
.
import requests
from bs4 import BeautifulSoup
url = 'https://connectedinvestors.com/member/jonathan-kessous/friends/2'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content, 'html.parser')
for tag in soup.find_all('div', class_="investorcard clearfix"):
h4 = tag.find('h4')
print(h4.a.text.strip(), tag.attrs['id'])
Output:
Jonathan Kessous 454517
Diunique Williams 950184
Aundre Price 989670
Larry Jackson 265408
Josie Djach 577911
.....ect
Let say want to take user id from.
Output:
/uploads/user/252881/img_552a543595cab.jpg
Here do the parser stop working as it's just text output,so can eg use regex.
>>> import re
>>>
>>> s = '/uploads/user/252881/img_552a543595cab.jpg'
>>> re.search( r"user/(\d+)", s).group(1)
'252881'