#๐ pinterest web web scraping
33 messages ยท Page 1 of 1 (latest)
@frigid pawn
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
import requests
from bs4 import BeautifulSoup
import time
import json
import re
# Getting pinterest image
WebhookDebugg = ""
pintrest_API = ""
user = "Quran_Project"
TargetUrl = f"https://www.pinterest.com/{user}/"
def FilterFunction(InsertedRequest):
InsertedRequest = requests.get(TargetUrl)
# check if the list is a list , and check if the request is vaild
if str(type(InsertedRequest)) == "<class 'requests.models.Response'>" :
# for Thing in HtmlFile:
HtmlFile = BeautifulSoup(InsertedRequest.text,'html.parser') # the returned html page
Tags = HtmlFile.find_all("script")
for script in Tags:
if script.string:
if len(script.string) > 15:
Images = set()
print("found it")
JsonString = str(HtmlFile)
StarterIndex = JsonString.find('"template_type":null},') # remove later
EndIndex = JsonString.rfind(',"traceLoggerData"') # remove later
if EndIndex != -1 :
JsonString = JsonString[:EndIndex]
print(JsonString[0:EndIndex],"")
print("SSSSSEESE")
pattern = re.compile(r'https://i\.pinimg\.com/(?!upload|30x30)[^"]+\.jpg') # idk some of this magic but here what it does
# find any url start with https//i/.pinimg.com/dont inculd any url that has upload or 30x30/more stuff /.jpg has to stop at jpg
matches = pattern.finditer(JsonString)
for match in matches:
Images.add(match.group(0))
return Images
else:
print("error ")
return "error"
# print(HtmlFile.prettify())
# print(f"\n \n {Tags.string} tt")
else:
# print an error
WhatWrong = f"Error with the respond, respond type = '{InsertedRequest.status_codes}' "
print(f"Error = {WhatWrong}, ")
Reqest = requests.get(TargetUrl)
print(type(Reqest),Reqest)
imageSet = FilterFunction(Reqest)
for Imagelink in imageSet:
print(Imagelink,end="\n")
print(len(imageSet))
also how to send long script discord is sooo greedy i cant send more than 500 characters
Have you read the ToS?
oh
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
so is there an api ?
can i get images by using the pinterest api?
i'm just guessing here, but i don't think what you want to do is covered by the API, because they probably don't want people downloading images from users instead of visiting the site
but i'm as i was saying, i'm just guessing
isn't that just for the pins owned by the logged in user?
Including public/private boards that the logged in user account have access to
but not pins owned by another user (even if they are public pins) that the logged in user has no connection/relation with, right?
that is, the other user hasn't specifically shared the board with the logged in user as a (public or private) group board to be shared between them
Get a Pin owned by the "operation user_account" - or on a group board that has been shared with this account.
or on a group board that has been shared with this account.
i have read that, but i don't think that means that you can go scrape other random users for all the images they have posted using the api, which i think is what OP is after
If the random user pins are public and its on a public or private board that the logged in user have access to, then yes, OP can access them.
If OP wants to get ALL pins public or private, without explicit access to their board from their logged in user account, then no.
have you punctually tested this yourself? (i haven't since i don't have an account)
i think that might be a misinterpretation if i read this documentation correctly (which i might not be doing)
to me that reads like you need to have a association or been delegated some kind of access to even be able to access such public pins that isn't your own
to me that reads like you need to have a association or been delegated some kind of access to even be able to access such public pins that isn't your own
Correct. I agree. That is what I said. What's the problem?
you said
If the random user pins are public and its on a public or private board that the logged in user have access to, then yes, OP can access them.
i'm interpreting what you said as if you think that OP can access all random users public pins without any association with those random users accounts
my interpretation of the documentation is that OP will not be able to do that unless given explicit access to a specific board by that random user account, even if the board or pins are public
either i'm interpreting your statement wrong
or you are interpreting my statement wrong
because to me it seems that we are interpreting the documentation differently from each other, and that it has very different implications for if OP can even use the API to their desired purpose or not
Clearly a miscommunication or misread. My statement did say
its on a public or private board that the logged in user have access to
So if the logged in user does not have access to the public/private board, then the logged in user cannot access those pins.
๐ฏ if OP decision is to scrape all pins regardless of access, the API won't do it
then i misinterpreted what you wrote
and as i understand it, OP wants to scrape images from random users public boards and pins that hey don't have any access to, other then to look at on the web like any other user without any association with that random user
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.