Jump to content
Sign in to follow this  
dil_bert

i want to run a python code in a phpBB-Extension - is this possible!?

Recommended Posts

Hello dear Community, 

 

i want to run a python code in a phpBB-Extension - is this possible!?

 

see the code - this i a parser.


import requests
from bs4 import BeautifulSoup
from concurrent.futures.thread import ThreadPoolExecutor

url = "my url"


def main(url, num):
    with requests.Session() as req:
        print(f"Collecting Page# {num}")
        r = req.get(url.format(num))
        soup = BeautifulSoup(r.content, 'html.parser')
        link = [item.get("href")
                for item in soup.findAll("a", rel="bookmark")]
        return set(link)


with ThreadPoolExecutor(max_workers=20) as executor:
    futures = [executor.submit(main, url, num)
               for num in [""]+[f"page/{x}/" for x in range(2, 50)]]

allin = []
for future in futures:
    allin.extend(future.result())


def parser(url):
    with requests.Session() as req:
        print(f"Extracting {url}")
        r = req.get(url)
        soup = BeautifulSoup(r.content, 'html.parser')
        target = [item.get_text(strip=True, separator=" ") for item in soup.find(
            "h3", class_="screen-reader-text").find_next("ul").findAll("li")[:8]]
        head = [soup.find("h1", class_="plugin-title").text]
        new = [x for x in target if x.startswith(
            ("V", "Las", "Ac", "W", "T", "P"))]
        return head + new


with ThreadPoolExecutor(max_workers=50) as executor1:
    futures1 = [executor1.submit(parser, url) for url in allin]

for future in futures1:
    print(future.result())

 


this is the output: 

 

Quote

[lorem ipsum dolor sit amet', 'Version: 2.34.1', 'Last updated: 5 months ago', 'Tags: magna aliquyam erat, sed diam voluptua. At vero eos et accusam']
[consetetur sadipscing elitr', 'Version: 6.54.1', 'Last updated: 5 months ago', 'Tags: lorem ipsum dolor sit amet']
[sed diam nonumy eirmod tempor invidunt ut labore', 'Version: 7.16.1', 'Last updated: 5 months ago', 'Tags: tarifa, sevilla lisabin invidunt ut labore et dolore magna aliquyam erat']
[tempor invidunt ut taria malaga jerusalem labore', 'Version: 9.58.1', 'Last updated: 5 months ago', 'Tags: ilabore et lissabon dolore magna aliquyam erat']

 

Notitzen-Feld: vgl. https://phpbb3.oxpus.net/dlext/details?df_id=37
 

Quote

Diese Modifikation stellt einen Bereich für persönliche Notizen bereit, den ausser dem User kein anderer einsehen kann.
An Notizen kann man sich dazu erinnern lassen.

 

News-Scroll: vgl. https://www.phpbb.com/community/viewtopic.php?t=2420771

Quote

Adds a scrolling text under the breadcrumbs of your forum. It can be configured to appear on all pages or just on the Index Page and/or for members only. You can preview the scrolling text in the ACP before displaying it on the forum. Special Characters, BBCodes and Emoticons supported, multiple lines of text allowed. Scrolling speed can be adjusted in the ACP the text will stop scrolling on mouseover and resume when you move the mouse.Automatic rtl switch included
Advertisment-Manager: vgl. https://www.phpbb.com/customise/db/extension/ads/
The Advertisement Management extension allows phpBB board administrators to add and manage advertisements on their forums. Features include: Create unlimited advertisements. Accepts code snippets (such as Google AdSense) or create your own HTML/JS ads. Add, edit, preview, disable, delete and banner image upload functionality in the Admin Control Panel.Display ads in a variety of locations and techniques (inline, pop-up, slide-up).Set ad priority to display important ads more often than others. Statistics: ad views and clicks can be counted. Option to assign an ad owner who can monitor their ad’s statistics. Option to expire ads after reaching a certain date or number of clicks and/or views. Option to hide ads for specific member group(s). Ad-Blocker detection option politely notifies users to disable ad blocking on the board. Ad code analysis can check for troublesome code such as JS alert() or making HTTP requests from a secure server.


Installation: https://www.phpbb.com/extensions/installing/

in one of the two mentioned blocks i want to run the above mentioned python code!? 

 

Share this post


Link to post
Share on other sites

The exec/system/passthru/shell_exec calls will allow you to run external programs or shell/os commands.  So yes, it should be possible.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.