Skip to content

add yelp image download#603

Merged
joshi1983 merged 3 commits intohhaccessibility:masterfrom
Yuanzjls:issue-411
Jul 29, 2018
Merged

add yelp image download#603
joshi1983 merged 3 commits intohhaccessibility:masterfrom
Yuanzjls:issue-411

Conversation

@Yuanzjls
Copy link
Copy Markdown
Collaborator

@Yuanzjls Yuanzjls commented Jul 3, 2018

migrate from python 2 to python 3, add yelp image download function

Copy link
Copy Markdown
Collaborator

@joshi1983 joshi1983 left a comment

Choose a reason for hiding this comment

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

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.

Comment thread importers/yelp.com/download_image.py Outdated
imag_save_url(url_yelp + next_url[0])
next_url = find_next_url(url_yelp + next_url[0])

#page = urllib.request.urlopen(url_img)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove the commented code. There isn't much point in keeping code that doesn't do anything.

Comment thread importers/yelp.com/download_image.py Outdated

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):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rename save_imag to save_image to complete the word.

Comment thread importers/yelp.com/download_image.py Outdated
with open(filename, 'wb') as html_file:
html_file.write(img_x);

def imag_save_url(url):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rename to image_save_url

Comment thread importers/yelp.com/download_html.py Outdated
html_file.close()
else:
print ('Already have details for location: ' + name)
print(('Already have details for location: ' + name))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are you using double brackets instead of what they were?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

@joshi1983 joshi1983 Jul 19, 2018

Choose a reason for hiding this comment

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

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)

Comment thread importers/yelp.com/download_html.py Outdated
html_file.close()
else:
print ('Already have details for location: ' + name)
print(('Already have details for location: ' + name))
Copy link
Copy Markdown
Collaborator

@joshi1983 joshi1983 Jul 19, 2018

Choose a reason for hiding this comment

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

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)

@joshi1983 joshi1983 merged commit b3f476a into hhaccessibility:master Jul 29, 2018
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