![]() |
|
[Python] Learn Advanced Python with HackForums! [EASY] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Learn Advanced Python with HackForums! [EASY] (/showthread.php?tid=5582794) Pages: Pages
1
2
|
Learn Advanced Python with HackForums! [EASY] - hunter24957 - Mar 24, 2017 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: ![]() 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 coloramaAnyways 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) * - Folks - Mar 24, 2017 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. * - hunter24957 - Mar 24, 2017 (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 😅 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. * - Ensky - Mar 24, 2017 Nice script man. Should come in useful for some people :) * - Folks - Mar 24, 2017 (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* 😉 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 🙃 * - Ensky - Mar 24, 2017 (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 :) * - SIM-1866423 - Mar 24, 2017 Bs4 just high level version of re ;) http://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head:/bs4/element.py PHP Code * - hunter24957 - Mar 24, 2017 (Mar 24, 2017 09:04 AM)_:O_ Wrote: Nice script man. Should come in useful for some people :)Thanks man! (Mar 24, 2017 09:59 AM)Mnemosyne Wrote: Bs4 just high level version of re ;) 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 bridgeAmen! 🤣 * - Malicious Intent - Mar 24, 2017 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: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':Sorry for the gramma and all but its really late here. * - hunter24957 - Mar 25, 2017 (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! 🤝 * - Malicious Intent - Mar 25, 2017 (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. * - GhostintheShock - Mar 25, 2017 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. * - Malicious Intent - Mar 25, 2017 (Mar 25, 2017 08:55 AM)mikewaals 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. * - ShennagigansDN - Mar 25, 2017 I get this when trying to run. I have installed the dependencies... Code File "hfpytutgrabber.py", line 48I'm running linux with standard python installs... Do I need to update my installs??? * - Nomad.Null - Mar 25, 2017 This is a pretty cool script! Thanks for sharing your source. Gave me a few ideas for some projects. 🤝 |