add yelp image download#603
Conversation
joshi1983
left a comment
There was a problem hiding this comment.
I had some trouble getting all the dependencies you used for Python 3.7 but will keep at that as you make these little tweaks.
| imag_save_url(url_yelp + next_url[0]) | ||
| next_url = find_next_url(url_yelp + next_url[0]) | ||
|
|
||
| #page = urllib.request.urlopen(url_img) |
There was a problem hiding this comment.
Remove the commented code. There isn't much point in keeping code that doesn't do anything.
|
|
||
| url_img = 'https://www.yelp.com/biz_photos/burma-superstar-san-francisco-2?select=UaR8ZJlXHHWO3t-47tp0jg' | ||
| url_yelp = 'https://www.yelp.com/' | ||
| def save_imag(url, filename): |
There was a problem hiding this comment.
rename save_imag to save_image to complete the word.
| with open(filename, 'wb') as html_file: | ||
| html_file.write(img_x); | ||
|
|
||
| def imag_save_url(url): |
There was a problem hiding this comment.
rename to image_save_url
| html_file.close() | ||
| else: | ||
| print ('Already have details for location: ' + name) | ||
| print(('Already have details for location: ' + name)) |
There was a problem hiding this comment.
Why are you using double brackets instead of what they were?
There was a problem hiding this comment.
I do not know, I just use the command 2to3 to migrate the code from python 2 to python 3, then it can work in Python3, however, I did not check this line, and I did not know it added double brackets.
There was a problem hiding this comment.
I think it is a little bug of the tool. The tool might have assumed there would be no brackets for the print statement's expression since the input was Python 2.7. This assumption is invalid as you can see.
Remove the extra brackets here and elsewhere in the file so the code looks better and give it a test run.
Something like this should work: print('Already have details for location: ' + name)
| html_file.close() | ||
| else: | ||
| print ('Already have details for location: ' + name) | ||
| print(('Already have details for location: ' + name)) |
There was a problem hiding this comment.
I think it is a little bug of the tool. The tool might have assumed there would be no brackets for the print statement's expression since the input was Python 2.7. This assumption is invalid as you can see.
Remove the extra brackets here and elsewhere in the file so the code looks better and give it a test run.
Something like this should work: print('Already have details for location: ' + name)
migrate from python 2 to python 3, add yelp image download function