Page 1 of 1

text in output as a message

Posted: 15. Sep 2021, 18:38
by felixschon
Dear Pushsafer,

I'm pretty new in coding and on your platform.
I have created a web scraper in Python, which prints me a specific text that is taken out of the website. I would like to set a notification that says the scraped text in the message (the text is different each time I run the process).

I managed to set up message notifications using your example:
From pushsafer import init, Client

init("<privatekey>")
Client("").send_message("Message", "Hello", "323", "1", "4", "2", "https://www.pushsafer.com", "Open Pushsafer", "0", "2", "60", "600", "1", "", "", "")

Example of my scrape:
for Word6 in soup.findAll(attrs={'example' : 'heyhowyoudoin'}):
print(Word6.text.strip())

However I can't figure out how to set the printed scraped text in the message automatically each time.

Thank you very much for your support.
Felix

Re: text in output as a message

Posted: 16. Sep 2021, 07:22
by admin
that should do the job

Code: Select all

init("<privatekey>")
Client("").send_message(Word6.text.strip(), "Hello", "323", "1", "4", "2", "https://www.pushsafer.com", "Open Pushsafer", "0", "2", "60", "600", "1", "", "", "")

Re: text in output as a message

Posted: 16. Sep 2021, 19:22
by felixschon
admin wrote:
16. Sep 2021, 07:22
that should do the job

Code: Select all

init("<privatekey>")
Client("").send_message(Word6.text.strip(), "Hello", "323", "1", "4", "2", "https://www.pushsafer.com", "Open Pushsafer", "0", "2", "60", "600", "1", "", "", "")
Thank you very much sir!
Should have thought of that before asking.
Now it sends me the notification, however the notification only includes the very last line scraped.
Lets say that Word6.text.strip() scrapes this from a website:

Apple is red
Orange is orange
Watermelon is green

The notification only includes 'Watermelon is green' even though it is all part of the Word6.text.strip() that is supposed to be notified.
Thank you very much for your time and sorry for beginner mistakes
Felix

Re: text in output as a message

Posted: 17. Sep 2021, 09:20
by admin
Hi, iam not a python pro

but try to change

Code: Select all

Word6.text.strip()
to

Code: Select all

Word6.text
strip() trim the text!