#๐Ÿ”’ pinterest web web scraping

33 messages ยท Page 1 of 1 (latest)

frigid pawn
#

so the problem is i want to get images from user in pinterest so i get some not all the images + "i can live with it but the returned page is all like json javescript not a html page "
so what should i do it return to me like 58 from 170

SOS i am soo lost with pinterest ๐Ÿ˜ญ

brazen hearthBOT
#

@frigid pawn

Python help channel opened

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.

frigid pawn
#

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

frigid pawn
#

oh

cobalt sage
#

!rule 5

brazen hearthBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

frigid pawn
#

so is there an api ?

frigid pawn
#

can i get images by using the pinterest api?

solar veldt
#

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

solar veldt
cobalt sage
solar veldt
cobalt sage
#

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.

solar veldt
#

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

cobalt sage
#

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.

solar veldt
cobalt sage
solar veldt
# cobalt sage > to me that reads like you need to have a association or been delegated some ki...

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

cobalt sage
#

๐Ÿ’ฏ if OP decision is to scrape all pins regardless of access, the API won't do it

solar veldt
#

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

brazen hearthBOT
#
Python help channel closed for inactivity

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.