Python Forum
how to find a particular id using python and bs4
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to find a particular id using python and bs4
#3
i received this error :

Traceback (most recent call last):
  File "C:\Users\prince.bhatia\Desktop\projects\image_delete_insert\Backend.py", line 34, in <module>
    returndata()
  File "C:\Users\prince.bhatia\Desktop\projects\image_delete_insert\Backend.py", line 31, in returndata
    trs = i.find_all("tr",{"id":re.match("^urltyp", i)})
  File "C:\Users\prince.bhatia\AppData\Local\Programs\Python\Python36\lib\re.py", line 172, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

hey, i have changed the match with compile and it is working..code:

def returndata():
    global login_url, url, final_data
    session_requests = requests.session()
    result = session_requests.post(login_url, payload).text
    result2 = session_requests.get(url).text
    soup = BeautifulSoup(result2, "html.parser")
    get_details = soup.find_all(id="entries")
    for i in get_details:
        trs = i.find_all("tr",{"id":re.compile("^urltyp")})
        print(trs)
        
returndata()
Reply


Messages In This Thread
RE: how to find a particular id using python and bs4 - by Prince_Bhatia - Sep-20-2018, 08:35 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020