-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add output param #9
Conversation
Thanks for taking the time to submit a PR @KennBro! It might be a few days before I can take a good look at it. |
I found that google returns different structures, so I added code to take into account the different outputs |
yagooglesearch/__init__.py
Outdated
except Exception: | ||
ROOT_LOGGER.warning(f"No title and desc for link") | ||
title = '' | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this continue
, it will go to the top of the for loop and not populate a "complete" dictionary for the result found. So setting title=""
does nothing.
The logic is if there is no title
(same for the desc
found later in the code), that search result would be discarded. Are you looking to have a result populated even if the title
or desc
isn't set found? I'd say yes (option 1), but wanted to confirm.
- Option 1, despite not all values being populated, the dictionary will be still added to the
unique_complete_result
list.
{
"url": "https://github.com",
"title": "GitHub site",
"desc": "",
}
- Option 2, not all values are populated, discard and don't return as part of the
unique_complete_result
list.
{
"url": "https://example.com",
"title": "",
"desc": "Example site description",
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need it to behave like option 1.
You are right, both 'continue' interfere with the behavior of option 1. I would only discard if the link does not exist.
Hey @KennBro - Had some changes to the PR that would be hard to go over through comments. Mind adding the option to allow me to commit changes to your PR? I've never done this, but did find this: If that doesn't work, I can just attach the updated files to this thread and have you copy/pasta them into your repo's files. |
The "Allow edits by maintainers" checkbox was checked since the beginning of the PR, as it says in the documentation. |
Hey @KennBro - Kept the spirit of your PR, but made a few tweaks:
Test it out and let me know what you think |
Awesome @opsdisk In the "Usage" example
I would comment out the proxy line because many people do copy/paste to test and that line would cause an error if they don't have the service (TOR for example) running on port 9050 And the other suggestion is to add the pysocks library because it is not in the requirements.txt and that causes the error...
If you want right now I make a new push with these suggestions |
Good suggestion...commented out the proxy line and pushed up to the PR. Also added you as a contributor to the README. For the SOCKS support, are you installing the dependencies through:
pip install -r requirements.txt or python setup.py install Either way, PySocks should be installed (because of https://2.python-requests.org/en/master/user/advanced/#socks I'd try it with a fresh virtual environment to doublecheck. I'll hold off on merging. |
Going to merge this one in. Appreciate the PR and working with you @KennBro. |
I needed the list of titles, description and urls of the searches
I added the output parameter that in case of taking the value "complete" returns a list [{"title": title, "desc": description, "url": url}, ...], for any other value returns the original output
I tested it with the following code
The default is "normal" which does not modify the original behavior of the program
I also added the output parameter to the documentation
I'll use the modification from my repo, but if you are interested you can merge it
Thank you very much for this software and Merry Christmas
KennBro