Sinisterly
[Ideas?] Reading raw HTML with Ruby - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Coding (https://sinister.ly/Forum-Coding--71)
+--- Thread: [Ideas?] Reading raw HTML with Ruby (/Thread-Ideas-Reading-raw-HTML-with-Ruby)



[Ideas?] Reading raw HTML with Ruby - Inori - 04-13-2015

I figured out how to do this a few days ago and I'm not sure what to do with it. Printing a page's worth of HTML to the console is impractical because it gets cut off usually about half way due to the number of lines exceeding the limit. I also thought about trying to find a single element buried in the page; like the name and URL of the last thread in coding, par example, but I have to use one hell of a long .include?() method.

If you guys have any ideas on what I could do with this, let me know.

(if you're interested, the code is here.)


RE: [Ideas?] Reading raw HTML with Ruby - 0xDEAD10CC - 04-18-2015

Parse the memberlist from this forum or something, and save it to a file. Not sure what kind of suggestions you are looking for?


RE: [Ideas?] Reading raw HTML with Ruby - Inori - 04-18-2015

(04-18-2015, 06:47 PM)0xDEAD10CC Wrote: Parse the memberlist from this forum or something, and save it to a file. Not sure what kind of suggestions you are looking for?

I'm still getting nokogiri (Ruby's XML/HAML reader) figured out and I've gotten a few ideas in the process, thanks though.


RE: [Ideas?] Reading raw HTML with Ruby - Eclipse - 04-18-2015

(04-18-2015, 06:47 PM)0xDEAD10CC Wrote: Parse the memberlist from this forum or something, and save it to a file. Not sure what kind of suggestions you are looking for?

Code:
from BeautifulSoup import BeautifulSoup import urllib2 page = urllib2.urlopen('https://sinister.ly/index.php') soup = BeautifulSoup(page) y = '' for x in soup.html.body.findAll('tr'): y = x.findAll('td') if y and 'users active in the past 60 minutes' in y[0].text: break unlist = '' for x in y: unlist = str(x) soup = BeautifulSoup(unlist) print 'Online Users:' count = 0 for x in soup.findAll('a'): count += 1 for z in x.findAll('span'): print str(count) + ' > ' + str(z.text) raw_input('\nPress anything to exit...')



RE: [Ideas?] Reading raw HTML with Ruby - 0xDEAD10CC - 04-19-2015

Nice, not sure how that would look in ruby, I don't really use Python as much anymore either.