-
-
Notifications
You must be signed in to change notification settings - Fork 633
Add function to traverse links using Breadth First Search #111
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
Conversation
|
@KingAkeem Awesome work 👏🏻. |
agrepravin
left a comment
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.
LGTM otherwise
|
|
||
| toVisit = list() | ||
| for link in links: | ||
| if targetLink == link and targetLink: |
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.
Don't see value of and condition here. If targetLink == link it will always be targetLink, right?
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 want to make sure targetLink since Python is a dynamic language, it's impossible to tell ahead of time what items a list may contain. If a None were to somehow get inserted, I don't want it to return a false positive.
modules/getweblinks.py
Outdated
| for link in links: | ||
| if targetLink == link and targetLink: | ||
| return depth | ||
| resp = requests.get(link) |
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.
What if errors out?
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.
Good catch, didn't think about that. I'm going to just put a try-except block and just pass errors. If there are errors, then we can just assume the link isn't valid.
Issue #102
Changes Proposed
Explanation of Changes
Two functions have been added, one which accepts the html of a webpage and an integer which represents the depth at which to stop. This function invokes the traversal function which searches the links using Breadth First Search algorithm.