Created
February 1, 2018 11:58
-
-
Save viveksb007/ff54cc5de6c30d8c8c81614114f171a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/magazines/photos/<number_of_images>', methods=['GET']) | |
def get_image_links(number_of_images): | |
image_list = [] | |
# Code for scraping zeolearn magazine section and appending links in image_list | |
response = requests.get('https://www.zeolearn.com/magazine/') | |
soup = BeautifulSoup(response.text, 'html.parser') | |
for tag in soup.find_all('img'): | |
image_list.append(tag['src']) | |
image_data = {} | |
if int(number_of_images) < len(image_list): | |
for i in range(0, int(number_of_images)): | |
image_data[str(i)] = image_list[i] | |
else: | |
for i in range(0, len(image_list)): | |
image_data[str(i)] = image_list[i] | |
return jsonify(image_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment