#๐Ÿ”’ scrapping photos off the internet

54 messages ยท Page 1 of 1 (latest)

jade acorn
shadow lintelBOT
#

@jade acorn

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.

jade acorn
#

ping or dm to answer

tropic sluice
#

From where? It may be

#

!rule 5

shadow lintelBOT
#

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

tropic sluice
#

@jade acorn

#

Also provide code as text

#

!code

shadow lintelBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

tropic sluice
#

And full code

#

If its too long

#

!paste

shadow lintelBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

tropic sluice
#

And also what are u expecting bc it looks like it works to me

#

Whats the goal

fallen sorrel
# jade acorn idk what to say other than wtf is going on ?????

You might want to do some error checking before trying to download the image. Make sure the URL is actually an image, perhaps you're saving the response of a 404 page or something to the file.

Also, you might want to keep the original file extensions lol

jade acorn
#

so good actually that if u look in the vid when i open the files through the terminal

#

everything is fine and i can c the pics

#

but idk why is it funky when i open file exploarer

#

i can't see the images all i c is that stuff u saw in the vid

#
  1. it is the same extentions
#

coz i take it from the orriginal link

#

and for my code

#
import requests
from bs4 import BeautifulSoup

response = requests.get("https://www.monsterhouseplans.com/house-plans/modern-farmhouse-style/2373-sq-ft-home-1-story-4-bedroom-2-bath-house-plans-plan50-381/")

soup = BeautifulSoup(response.content, "html.parser")

tag = soup.find(name="div", class_ = "housePlanDetailTitleLeftSec").find("strong").text[1:]
specs = soup.find(name="div", class_ = "housePlanKeySpecs").find_all(name="li")

list_specs = []

for e in specs:
    list_specs.append(e.find("span").text.lstrip().rstrip().split()[0])

plans = soup.find_all(name="div", class_="housePlanFieldSetHolder")

names = []
sorces = []

for plan in plans:
    images = plan.find_all("img")
    for image in images:
        names.append(image.get("alt"))
        sorces.append(image.get("data-src"))

for e in list(range(len(names))):
    response = requests.get(sorces[e]).content
    filename = f"{names[e]}.{sorces[e].split(".")[-1]}"
    print(filename)
    with open(filename, "wb") as fp:
        fp.write(response)
#

here u guys go

#

@tropic sluice

#

@fallen sorrel

fallen sorrel
#

It's creating a blank text file?

jade acorn
#

yes

#

and the image is no where to be seen in the file exploarer

fallen sorrel
#

Hmm, I just ran the code and it seems to be working

#

these 5 images are downloaded correctly

tropic sluice
#

Try refreshing the explorer

#

Right click and there should be an option for that

languid shell
#

laminar what OS are you using?

fallen sorrel
#

I'm on Linux

languid shell
#

And they're on windows. I'm thinking the : character might be messing with things because that's not a valid character for filenames for windows

fallen sorrel
#

Oh that's true

#

Good thinking

languid shell
#

Since your files seem to appear fine in vs code but theirs are not. Not sure what's going on with selecting them from the console though

#

@jade acorn try cleaning the filenames from special characters that windows doesn't allow

jade acorn
#

ohhhhhhh

#

alr great idea

#

ty guys

#

u r the best

tropic sluice
#

If it solved it use !solved to close the thread

jade acorn
#

!solved

shadow lintelBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.