#I Could need help here im new to Python

206 messages · Page 1 of 1 (latest)

grim coral
#

just say if you need full code

sacred mauveBOT
#

@grim coral

File Attachments Not Allowed

For safety reasons we do not allow files with certain file extensions.

Code Formatting

You can share your code using triple backticks like this:
```
YOUR CODE
```

Large Portions of Code

For longer scripts use Hastebin or GitHub Gists and share the link here

Ignored these files due to them having disallowed file extensions
cosmic prism
#

Selenium trash moment

#

But yeah we need full code kek

#

Probably an issue with scrolling

#

Just fyi, viewbotting is against tos and viewbotting with Selenium is a bad idea, you'll spend more on servers than you could ever make from renting the bot out 🙂

grim coral
#

yeah but like I said not mine and im new to Python 😬 but I can send full code

sacred mauveBOT
#

@grim coral

File Attachments Not Allowed

For safety reasons we do not allow files with certain file extensions.

Code Formatting

You can share your code using triple backticks like this:
```
YOUR CODE
```

Large Portions of Code

For longer scripts use Hastebin or GitHub Gists and share the link here

Ignored these files due to them having disallowed file extensions
  • message.txt
grim coral
#

hooow

#

xd

cosmic prism
#

Can you read?

cosmic prism
cosmic prism
grim coral
#

fr

cosmic prism
#

Damn we just copying code from github and putting our name in the title bar now

#

Very nice

grim coral
#

Instead of trying to do jokes about me or smth you could just help me

#

Or did I say any bad

cosmic prism
#

The issue is that the original author also doesn't know Python

#

So basically in line 119

grim coral
#

The thing is it worked like 1-2 months ago

#

but now it doesnt anymore

#

after I resetted my pc

cosmic prism
#

It's broken for all of the funny proxies you have in there, correct?

grim coral
#

yes

cosmic prism
#

A sleep between line 117 and 119 would probably be enough

#

(you can figure out how to sleep in Python on your own, I believe in you)

#

But the application probably won't scale much beyond like 10 or 15 viewers

You could use all of the proxies at the same time but even then it'd be pretty resource-intensive

grim coral
#

Yeah I tried and it worked like 20-30 without lags

grim coral
#

did it like this now

#

dont know if its right but its still not working

#

You have any other idea?

cosmic prism
#

I'd suggest to get rid of the --headless flag in line 107 so you can see what it's doing

grim coral
#

hmmm

#

there are cookies on the website

#

could it be the problem?

cosmic prism
#

Maybe you have to accept the funny GDPR cookie banner first

#

Can you click on the URL bar without accepting cookies?

grim coral
#

yes

#

how can I do it so it accepts it automaticly

cosmic prism
#

Open the dev tools

#

Ctrl + Shift + I

#

Clicc through the funny HTML and locate the cookie accept button

#

(Copy XPath or it's ID then driver.find_element by id or by xpath that element and then element.clicc it)

grim coral
#

So I know what you mean but I don't know how to implement it

#

Could you help me there?

cosmic prism
#

What part are you struggling with exactly?

#

I won't write any code for you, sorry

grim coral
#

First I dont know how to find out the button. I mean its like this rn but im not sure if I do it right

cosmic prism
#

That's the button

#

Now you just gotta figure out how to target that button

#

It doesn't have a nice CSS class like the URL input, but you could still right click it in the HTML explorer in the dev tools and copy the XPath

grim coral
#

what do you mean with XPath?

cosmic prism
#

Right click copy as xpath

#

xpath is some magic way of identifying things in other XML or HTML documents

grim coral
#

So

#

I got this

#

/html/body/div[8]/div[2]/div[1]/div[2]/div[2]/button[1]/p

#

and now?

cosmic prism
#

So now you go back to thec ode

cosmic prism
#

"selenium click button by xpath python" on Google -> copy pasta

grim coral
#

betweeeeennnn

#

timesleep?

cosmic prism
#

Somewhere between sleeping (aka waiting for the page to load) and clicking the button so exactly there, yes

grim coral
#

i saw on google

#

and did this

#

is it wrong?

cosmic prism
#

I'd probably go with the second approach but whatever

#

Now try running again and see if it automagically accpets cookies

#

Oh damn they removed that method

grim coral
#

😮

#

That does mean?

cosmic prism
#

Haven't used Selenium in years, apparently they removed it in 2022 or so

#

driver.find_element("xpath", "some/xpath/here") should work though

#

Can you drop the link to the proxy in here? I want to take a look at the HTML myself

#

But it looks like something's wrong with the XPath

#

lol I don't even get the funny cookie banner

#

nice

grim coral
#

lol

#

open other browser maybe

cosmic prism
#

Ah nevermind I have a magic firefox extension that just nukes all of those cookie banners

#

In chrome it's bitching to me again

grim coral
#

yea that

cosmic prism
#

You probably want to click the actual button and not the text inside of the button

#

/html/body/div[8]/div[2]/div[1]/div[2]/div[2]/button[1]

#

So this one maybe

grim coral
#

😬 ..

#

huh

#

but isnt it the same

#

Yea its the same

cosmic prism
#

So does the form show up in time?

grim coral
#

wdym

cosmic prism
#

Does it try to click before the consent form is visible?

grim coral
#

How can i see/check it?

cosmic prism
#

add more sleeps and more prints 🗿

grim coral
#

spammed it to check

#

but its doing nothing

cosmic prism
#

It'll crash in the first one

#

I'm saying you run the script and see if it pops up in time

grim coral
#

Uh

#

i could try to explain what happens

cosmic prism
#

Go ahead

grim coral
#

after the browser open it opens the website

#

after opening the website it opens a new tab with the same website

#

than it pops up (the cookie thing)

#

and after like 5-10 seconds it crashes and shows me error code

cosmic prism
#

So we open the website, open the new tab (driver.execute_script... and driver.switch_to.window(...))

#

So it's still not finding the cookie magic for some reason

grim coral
#

yea

#

So what should I do now

cosmic prism
#

You're running driver.find_element(xpath)

cosmic prism
#

with the xpath being the second argument

grim coral
#

So you mean like this

#

?

cosmic prism
#

Yup

grim coral
#

Still not working

cosmic prism
#

Why?

grim coral
#

idk

#

still stuck at the cookies

#

wait

#

the cookies where gone

#

but than it crashed

cosmic prism
#

So cookie issue is solved

#

Now let's see why it crashes now

#

Do you still try to click the button multiple times? Is the button gone now that you have clicked it once?

#

Not sure how Selenium on Windows handles browser profiles

grim coral
#

it needs like 6 seconds for the cookies to be gone

cosmic prism
#

Because of the sleep(5)?

grim coral
#

its working now i think

#

nah

#

not working

cosmic prism
#

Probably breaks on the second tab because there's no cookie popup there?

grim coral
#

Nah i tried with one only and it worked

#

with 10 it doesnt

cosmic prism
#

Exactly what I said, no?

grim coral
#

nah not really

#

wait ill explain in 2 min

#

so if i say 2 viewers not 1 it opens 2 windows yk not tabs

#

but it only works for 1 window

#

if i say i want 10 viewers it crashes

cosmic prism
#

Does it show the cookie popup again in the new windows, or only in the first one?

grim coral
#

ah wait i daid it wrong

#

its not opening windows its opening tabs sorry for missunderstanding

#

on the first tab its doing nothing

#

on the second its going right

#

the third one is just doing nothing but doesnt have cookies

cosmic prism
grim coral
#

yes ik sorry mb

cosmic prism
#

You only need to close the cookie popup in the first tab

grim coral
#

uh wdym now

#

and its only opening 3 tabs

#

if i put 10 viewers its still 3 tabs

#

and crashes than

grim coral
#

crashes than

#

if i do it

#

what should I do now

#

so

#

i did 2 now

#

on one tab it accepts cookies and works

#

the other one doesnt have cookies than

#

but just crashes

grim coral
#

Still not working

#

I did

cosmic prism
#

How'd you modify the code?

grim coral
#

Thats everything

cosmic prism
#

looks like exactly the same code you had before

grim coral
#

What should I change

grim coral
#

yeah but I did

#

and than its crashing

cosmic prism
#

What code did you change

grim coral
#

only this

grim coral
#

What

#

do

#

you

#

mean

cosmic prism
grim coral
#

Nothing actually

cosmic prism
#

So why would it magically work

grim coral
#

What should i change?

cosmic prism
#

Did you read any of my previous messages?

grim coral
#

You mean this

#

right?

#

But now

#

Do you mean to change it in code our do i have to close the cookies by myself

cosmic prism
#

Whatever you preferkek

obtuse cargo
#

hey i can help!

plucky fable
#

then help lol

grim coral
#

Is there a way to make the main.py to an application?

#

I dont know how that works

cosmic prism
#

Python is not supposed to be packed into .exe files

grim coral
#

not?

#

but why not

cosmic prism
#

Because it's not made to ship executables to end users