Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fallbacks for finding description and title #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

isaacwasserman
Copy link

I noticed that a lot of my searches were returning no results because search() couldn't locate the description, so I made some changes that allow it to return a result as long as the link is found. If the description is not found using -webkit-line-clamp: 2, then it looks for a within the result that has as an immediate child. If this is also unsuccessful, it simply returns a concatenation of all of the visible text within the result. This isn't a perfect solution for human readability, but it's still helpful to AI agents that will make use of this package.

Copy link
Owner

@Nv7-GitHub Nv7-GitHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It overall looks good, I will try to pull it and test it in a couple of weeks!


# Parse
soup = BeautifulSoup(resp.text, "html.parser")
result_block = soup.find_all("div", attrs={"class": "g"})
if len(result_block) ==0:
if len(result_block) == 0:
print("Result block empty")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't have a print here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants