Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Learn Advanced Python with HackForums! [EASY]

Want to learn Python quickly through HackForums with no hassle?
If the answer is yes, then this is what you need!

I was screwing around with logging into HackForums via Python when I came up with an idea.
I decided to act on it and created a nifty little gadget that will grab random posts from the Python section right here ONLY marked with the tags: [Release], [Source], [Tutorial].
But of course, like the whole source code, that is changeable. This will allow users to find post which they may not know they're looking for.
It should also (hopefully) help to inspire some users into creating things and getting more in-depth into Python.

You're free to make the code Object Orientated or whatever you would like to do, I whipped it up quickly as it's getting REALLY later right now.
And I'm currently rushing this post also. I know at least one user can benefit from this, so I'm posting it ASAP.

Now I'm not saying the posts it will give you are correct or "advanced", but they sure as hell should help to inspire some people.

Here's a screenshot:
[Image: VRSM1r0.png]

As you can see it's color coded to make it more user friendly and easy to differentiate between things, this was achieved with colorama, you'll need to install it along with bs4 and requests, like so:
Code
pip install colorama
pip install requests
pip install bs4

Anyways here's the code, I hope you guys enjoy it!
Spoiler (Click to View)
(Yes I know the code is horrible, it bugs me as well, but this is not my top project; you'll have to do the sorting)
Beautiful, I was trying to figure out beutiful soup for my IG downloader but just decided to keep it simple. I remember you making a hackforums username checker too which is super cool but it got removed because rules 😅

I'll take a look into cleaning up the code for you because I enjoy doing it, after class.
(Mar 24, 2017 08:45 AM)Folks Wrote:  Beautiful, I was trying to figure out beutiful soup for my IG downloader but just decided to keep it simple. I remember you making a hackforums username checker too which is super cool but it got removed because rules 😅

I'll take a look into cleaning up the code for you because I enjoy doing it, after class.

Thanks for the feedback. It was unfortunate to say the least. Although it's still on my pastebin *wink* *wink* 😉

Even though I use BS4, I do not recommend it; the lead developer has even suggested to use something else because the project is not longer getting updated.
Unfortunately, I know it well enough to not be able to transition. I recommend trying something like LXML, it's a great alternative and better than using RE and/or BS4.
Nice script man. Should come in useful for some people :)
(Mar 24, 2017 08:51 AM)hunter24957 Wrote:  Thanks for the feedback. It was unfortunate to say the least. Although it's still on my pastebin *wink* *wink* 😉

Even though I use BS4, I do not recommend it; the lead developer has even suggested to use something else because the project is not longer getting updated.
Unfortunately, I know it well enough to not be able to transition. I recommend trying something like LXML, it's a great alternative and better than using RE and/or BS4.

Regular expressions have made me contemplate jumping off the nearest bridge. I'll have to learn it at some point but I'd rather not 🙃
(Mar 24, 2017 09:48 AM)Folks Wrote:  Regular expressions have made me contemplate jumping off the nearest bridge. I'll have to learn it at some point but I'd rather not 🙃

They're pretty easy--they look confusing but they aren't :)
Bs4 just high level version of re ;)

http://bazaar.launchpad.net/~leonardr/be...element.py

PHP Code

<?php 
# /^([a-zA-Z0-9][-.a-zA-Z0-9:_]*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
    #   \---------------------------/  \---/\-------------/    \-------/
    #     |                              |         |               |
    #     |                              |         |           The value
    #     |                              |    ~,|,^,$,* or =
    #     |                           Attribute
    #    Tag
    
attribselect_re = re.compile(
        
r'^(?P<tag>[a-zA-Z0-9][-.a-zA-Z0-9:_]*)?\[(?P<attribute>[\w-]+)(?P<operator>[=~\|\^\$\*]?)' +
        
r'=?"?(?P<value>[^\]"]*)"?\]$'
        
) 
(Mar 24, 2017 09:04 AM)Ensky Wrote:  Nice script man. Should come in useful for some people :)
Thanks man!


(Mar 24, 2017 09:59 AM)SIM-1866423 Wrote:  Bs4 just high level version of re ;)

http://bazaar.launchpad.net/~leonardr/be...element.py

PHP Code

<?php 
# /^([a-zA-Z0-9][-.a-zA-Z0-9:_]*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
    #   \---------------------------/  \---/\-------------/    \-------/
    #     |                              |         |               |
    #     |                              |         |           The value
    #     |                              |    ~,|,^,$,* or =
    #     |                           Attribute
    #    Tag
    
attribselect_re = re.compile(
        
r'^(?P<tag>[a-zA-Z0-9][-.a-zA-Z0-9:_]*)?\[(?P<attribute>[\w-]+)(?P<operator>[=~\|\^\$\*]?)' +
        
r'=?"?(?P<value>[^\]"]*)"?\]$'
        
) 

Very true, but still slow as hell.

Nice example by the way, you've just reminded me why I don't use regular expressions 😏


(Mar 24, 2017 09:48 AM)Folks Wrote:  Regular expressions have made me contemplate jumping off the nearest bridge. I'll have to learn it at some point but I'd rather not 🙃

Same here, I know a little about them but they just never come useful to me and the fact it takes quite a bit of time to learn them.

(Mar 24, 2017 09:48 AM)Folks Wrote:  Regular expressions have made me contemplate jumping off the nearest bridge
Amen! 🤣
Nice scrapper buddy. In Python2 input() is integer by default so no need to convert it, raw_input() is a string but in Python3 it was simplified and only input() is used.

i refer to this line: It only makes sense if you add exception handling.
Code
amount = int(input('How many posts would you like to grab? '))

You did add exception handler in the part below.

Code
try:
        # prompts user for the post number
        option =int( input('Please select a post number: '))
except TypeError:
        print('Invalid post number entered.')
        continue

I understand you wanted to enforce number input and throw exception if string but for this to work you need to use

Code
except ValueError:

Instead of your TypeError:.

Other than that nice scraper and definitelly people will find it useful. Well done.

Also to make your code run smoothly on linux you can use
Code
if os.name=='nt':
    os.system('cls')
elif os.name=='posix':
    os.system('clear')
As oppose to os.system('cls') ... You can also check for other OS's this way.(its not the only way but its probably the most popular)

Sorry for the gramma and all but its really late here.
[Image: V9Gredc.png]
(Mar 24, 2017 10:18 PM)Malicious Intent Wrote:  Nice scrapper buddy. In Python2 input() is integer by default so no need to convert it, raw_input() is a string but in Python3 it was simplified and only input() is used.

This has been written in Python 3.6.1 and the exception handling works on my end, the exception handling is just for an invalid index, I haven't added any for TypeErrors, feel free to include them! 🤝
(Mar 25, 2017 06:19 AM)hunter24957 Wrote:  This has been written in Python 3.6.1 and the exception handling works on my end, the exception handling is just for an invalid index, I haven't added any for TypeErrors, feel free to include them! 🤝

I see.. As it was really late or rather early when i tested it.. I have both versions installed and used Python3 to run it. Since i'm used to Python2 more that int() got my attention and i decided to try different inputs to see how it behaves. On my end it would crash and exit when string passed,obviosuly it was meant to be a integer not a string so the input error was expected. When i passed numbers everything worked as it should other than cls but thats just coz i use linux.

When i added TypeError the program would continue and prompt accordingly regardless what values passed. Than again, I just like to test code for all possible outcomes and thats the only reason i mentioned TypeError. Nice to see more folks using Python.
[Image: V9Gredc.png]
Very happy to see this thread. I am also learning Python. Beautiful Soup is one of the best parsing modules in Python. Have used it to convert many exploits to automatic one.
(Mar 25, 2017 08:55 AM)GhostintheShock Wrote:  Very happy to see this thread. I am also learning Python. Beautiful Soup is one of the best parsing modules in Python. Have used it to convert many exploits to automatic one.

Yep BS is great. You should also try Selenium if you need to parse js. I think qt and webkit also support it but not sure.
[Image: V9Gredc.png]
I get this when trying to run. I have installed the dependencies...
Code
File "hfpytutgrabber.py", line 48
    print(Fore.LIGHTRED_EX, end='\r')
                               ^
SyntaxError: invalid syntax

I'm running linux with standard python installs... Do I need to update my installs???
Visit my STORE !
This is a pretty cool script! Thanks for sharing your source. Gave me a few ideas for some projects. 🤝
Malware Dev & Grey Hat available for contract work. DM if you need me.

OSCP, OSCE, OSEE, OSWE, OSWP, CEH, CISSP

Yeah, I've been around a while


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Release] by redoApr 3, 2026 01:38 AM 0 95 Apr 3, 2026 01:38 AM
Last Post: redo
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by gravity_0Aug 20, 2023 01:32 AM 18 1,074 Aug 20, 2023 01:32 AM
Last Post: Lucky4L