Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
B
Bot messenger
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Déploiement
Releases
Registre de conteneurs
Registre de modèles
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Loïc DUBARD
Bot messenger
Validations
9d935aff
Valider
9d935aff
rédigé
Il y a 5 ans
par
Loïc Wikle DUBARD
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
shitpostbot insta parser
parent
3ff95db5
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
bot.py
+7
-3
7 ajouts, 3 suppressions
bot.py
useless/shitpostbot5k.py
+26
-9
26 ajouts, 9 suppressions
useless/shitpostbot5k.py
avec
33 ajouts
et
12 suppressions
bot.py
+
7
−
3
Voir le fichier @
9d935aff
...
@@ -59,7 +59,7 @@ class Bot(Client):
...
@@ -59,7 +59,7 @@ class Bot(Client):
'
!memes <image_name_or_url> ; <texte1> ; <texte2(facultatif)> ... not yet implemented
\n
'
+
\
'
!memes <image_name_or_url> ; <texte1> ; <texte2(facultatif)> ... not yet implemented
\n
'
+
\
'
!ping
\n
'
+
\
'
!ping
\n
'
+
\
'
!translate <phrase> ; <lang_source> ; <lang_dest>
\n
'
+
\
'
!translate <phrase> ; <lang_source> ; <lang_dest>
\n
'
+
\
'
!shitpostbot5000 [status|on|off|random] ... ne pas utiliser PLEASE
\n
'
+
\
'
!shitpostbot5000 [status|on|off|random
|timer
] ... ne pas utiliser PLEASE
\n
'
+
\
'
!about -> vas-y test-moi !
\n
'
'
!about -> vas-y test-moi !
\n
'
return
help_text
return
help_text
elif
'
!translate
'
in
texte
:
elif
'
!translate
'
in
texte
:
...
@@ -102,8 +102,12 @@ class Bot(Client):
...
@@ -102,8 +102,12 @@ class Bot(Client):
elif
texte
==
'
!shitpostbot5000 off
'
:
elif
texte
==
'
!shitpostbot5000 off
'
:
if
thread_id
in
Bot
.
shitpostbot
:
if
thread_id
in
Bot
.
shitpostbot
:
Bot
.
shitpostbot
[
thread_id
][
0
].
set_off
()
Bot
.
shitpostbot
[
thread_id
][
0
].
set_off
()
elif
texte
==
'
!shitpostbot5000 random
'
:
elif
'
!shitpostbot5000 random
'
in
texte
:
self
.
sendLocalImage
(
Shitpostbot5000
.
random
(),
thread_id
=
thread_id
,
thread_type
=
thread_type
)
texte
=
texte
.
replace
(
'
!shitpostbot5000 random
'
,
''
)
if
texte
==
''
:
return
Shitpostbot5000
.
random
()
else
:
return
Shitpostbot5000
.
random
(
texte
)
# pour rigoler
# pour rigoler
elif
'
!memes templates
'
in
texte
:
elif
'
!memes templates
'
in
texte
:
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
useless/shitpostbot5k.py
+
26
−
9
Voir le fichier @
9d935aff
...
@@ -3,7 +3,12 @@ from urllib.request import urlopen
...
@@ -3,7 +3,12 @@ from urllib.request import urlopen
from
bs4
import
BeautifulSoup
from
bs4
import
BeautifulSoup
import
re
import
re
import
urllib.request
import
urllib.request
import
urllib.parse
import
urllib.error
import
datetime
import
datetime
import
ssl
import
json
import
random
class
Shitpostbot5000
(
object
):
class
Shitpostbot5000
(
object
):
...
@@ -39,15 +44,27 @@ class Shitpostbot5000(object):
...
@@ -39,15 +44,27 @@ class Shitpostbot5000(object):
return
self
.
out
return
self
.
out
@classmethod
@classmethod
def
random
(
self
):
def
getlinks
(
self
,
hashtag
,
url
):
html
=
urlopen
(
'
https://www.facebook.com/pg/shitpostbot5k/photos
'
)
html
=
urllib
.
request
.
urlopen
(
url
,
context
=
self
.
ctx
).
read
()
bs
=
BeautifulSoup
(
html
,
'
html.parser
'
)
soup
=
BeautifulSoup
(
html
,
'
html.parser
'
)
images
=
bs
.
find_all
(
'
img
'
,
{
'
src
'
:
re
.
compile
(
'
.jpg
'
)})
script
=
soup
.
find
(
'
script
'
,
text
=
lambda
t
:
t
.
startswith
(
'
window._sharedData
'
))
images2
=
bs
.
find_all
(
'
image_src
'
)
page_json
=
script
.
text
.
split
(
'
=
'
,
1
)[
1
].
rstrip
(
'
;
'
)
for
image
in
images
:
data
=
json
.
loads
(
page_json
)
print
(
image
[
"
src
"
])
print
(
'
Scraping links with #
'
+
hashtag
+
"
...........
"
)
return
None
links
=
[]
for
post
in
data
[
'
entry_data
'
][
'
TagPage
'
][
0
][
'
graphql
'
][
'
hashtag
'
][
'
edge_hashtag_to_media
'
][
'
edges
'
]:
image_src
=
post
[
'
node
'
][
'
thumbnail_resources
'
][
1
][
'
src
'
]
links
.
append
(
image_src
)
return
links
@classmethod
def
random
(
self
,
hashtag
=
random
.
choice
([
'
shitpostmeme
'
,
'
shitpost
'
,
'
shitposts
'
,
'
memes
'
,
'
climbingmemes
'
,
'
rockclimbingmemes
'
,
'
climbingmemesaredank
'
,
'
climbingmemesofinstagram
'
])):
self
.
ctx
=
ssl
.
create_default_context
()
self
.
ctx
.
check_hostname
=
False
self
.
ctx
.
verify_mode
=
ssl
.
CERT_NONE
return
random
.
choice
(
self
.
getlinks
(
hashtag
,
'
https://www.instagram.com/explore/tags/
'
+
hashtag
+
'
/
'
))
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
img
=
Shitpostbot5000
()
img
=
Shitpostbot5000
()
print
(
img
.
get_latest
(
))
print
(
Shitpostbot5000
.
random
(
'
shitposts
'
))
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter