James MAkkoy
James MAkkoy

Reputation: 25

list element 'list' object has no attribute 'replace'

jlink1=[]
import time
#for url in l2:
jdata=len(l2)
for i in range(jdata):
    time.sleep(0.5)
    url =l2[i] 
    page = requests.get(url).content
    soup = BeautifulSoup(page, 'html.parser')     
    for tr in soup.find_all('td', attrs={'class':'fsdfsdfsdfsdfi'}):
        sikko1 =[ x.get("href") for x in tr.find_all('a',)]  
        jlink1.append(sikko1)    
        print(sikko1)
['../Page/../sdfsdfsdfsdf']
['../Page/../sdfsfsdfsdfsdfsdf']
['../Page/../sdfsfsdfsdfsdfsfsfd']
['../Page/../sdfsfsdfsfsdfsdfsdf']

İ have just like this list and can't convert string for use this code

jlink1.replace('../..','https://www.blablfsddfda.com')

Help please

Upvotes: 1

Views: 139

Answers (1)

oreopot
oreopot

Reputation: 3450

replace the following piece of code:

sikko1 =[ x.get("href") for x in tr.find_all('a',)]

to the following:

sikko1 =[ x.get("href").replace('../','https://www.blablfsddfda.com') for x in tr.find_all('a',)]

Upvotes: 2

Related Questions