Get Some String data from web site

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?

You could do that with urllib. urllib.request — Extensible library for opening URLs — Python 3.9.2 documentation

1 Like

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

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

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

When do you have to send the message exactly?

@Ryan when i write

import requests

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

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+")")

where will we write this code ?

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?

@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.

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

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

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

What exactly do we need to do

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
2 Likes

@JellyBitz

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

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

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

1 Like

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

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