Get Some String data from web site


#1

i need a plugin/code for Login to any website and get data from website, and i have to write that data to Botchecker via pm… is anyone have it?


#2

You could do that with urllib. https://docs.python.org/3/library/urllib.request.html


#3

you are professional and i dont know how to use it lol.


#4

At rsilkroad.com we have to take this code on a string or integer. As a “kervankey” i dont know python i know c# anyways can you do it for me Ryan? We have to send that code to botchecker char as pm


#5

Pretty sure this is pointless because you can’t even buy the trade items with the bot.


#6

When do you have to send the message exactly?


#7

@Ryan when i write

import requests

its failing how can i register that import? requests and BeautifulSoup modules


#8

Here an example, just try it. But I’m not sure if it’s possible to add this kind of code at plugins loading.

urllib.request
from phBot import *
import urllib.request

# Get Url stream data
response = urllib.request.urlopen('http://rsilkroad.com/')

# Reading all data
html = response.read().decode('utf-8')

# Parsing html specific data <span id="KervanKey" class="text-orange">XXX</span>
pos = html.find('<span id="KervanKey" class="text-orange">') # 41 characters used to find the right position
kervankey = html[pos+41:pos+41+3] # three number key
xkervankey = html[pos+41:pos+41+10].split("<")[0] # in case is not only three number key

log("Plugin: KervanKey ("+kervankey+") - xKervanKey ("+xkervankey+")")

#9

where will we write this code ?


#10

this code is false bro. we get this error code “Python Error: HTTP Error 403: Forbidden” in Phbot Log. What will we do with this?


#11

@JellyBitz Unfortunately that’s not going to work because they added Cloudflare rate limiting and probably browser checking as well. If you’re able to get the key one time it probably won’t work the second time.


#12

is there any command about “Reload Plugins” for every teleport?


#13

Ryan what is your advice for this code? We’re working on this code from 10 a.m but we can’t solve it.


#14

You could make it read from a text file that you place the key in manually.


Trade Chat Answer
#15

What exactly do we need to do


#16

Edit: fixed and working now! Thanks to @Muptezhello for his interest at helping… :slight_smile:

kervankey.py
from phBot import *
import phBotChat
from time import sleep
import urllib.request

log("Plugin: KervanKey successfully loaded.")

# Return string containing the kervankey
def getKervanKey():
	# Emulating a quick browser
	req = urllib.request.Request("http://rsilkroad.com/", headers={'User-Agent' : "JellyBrowser"})
	# Getting stream
	resp = urllib.request.urlopen(req)
	# Getting html data
	html = str(resp.read().decode("utf-8"))  # => "<!DOCTYPE html><html><head>..."
	# Extracting data: <span id="KervanKey" class="text-orange">XXX</span>
	pos = html.find('<span id="KervanKey" class="text-orange">') # 41 characters used to find the right position
	kervankey = html[pos+41:pos+41+10].split("<")[0] # in case is not only three number key
	log("Plugin: KervanKey extracted ("+kervankey+")")
	return kervankey

def handle_chat(t, player, msg):
	if len(player) > 0:
		if player == "BotCheck" and "BotCheck" in msg:
			sleep(1.0)
			phBotChat.Private(player,getKervanKey())

getKervanKey() # just for test purpose at loading

#17

@JellyBitz

[00:23:26] Plugin: cfscrape.py failed to load

[00:23:26] Plugin: kervankey.py failed to load


#18

I wouldn’t rely on external scripts like that. Just use regex to find the ‘Kervankey’ text. https://regex101.com/

Something like this:

Kervankey: (\d*)

Edit:

import re
re.search(r'Kervankey: (\d*)', text)[1]

image


#20

someone broke the key Ryan can u do anything for us ?


#21

where we can send to phbot plugin and how we can work it and how we can try its work or doesnt work