Skip to content

IndexError: list index out of range #4

Description

@danielg-everc

Hi Im trying to use search_by_url method and Im getting the following:
IndexError: list index out of range

full error
File , line 4
1 from googlelens import GoogleLens
2 lens = GoogleLens()
----> 4 search_result = lens.search_by_url("https://ae01.alicdn.com/kf/S52a81a68ba6c4dd2ba057a7e019092d6f.jpg" target="_blank" rel="noopener noreferrer">https://ae01.alicdn.com/kf/S52a81a68ba6c4dd2ba057a7e019092d6f.jpg")
5 print(search_result)

 in GoogleLens.__get_prerender_script(self, page)
 32 soup = BeautifulSoup(page, 'html.parser')
 34 # Find the script containing 'AF_initDataCallback' with specific key and hash values

---> 35 prerender_script = list(filter(
36 lambda s: (
37 'AF_initDataCallback(' in s.text and
38 re.search(r"key: 'ds:(\d+)'", s.text).group(1) == "0"),
39 soup.find_all('script')
40 ))[0].text
42 # Clean up the script content to prepare it for JSON parsing
43 prerender_script = prerender_script.replace(
44 "AF_initDataCallback(", "").replace(");", "")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions