Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. # coding: utf-8
  2.  
  3. require 'test_helper'
  4.  
  5. class TestGoogleDoodler < Test::Unit::TestCase
  6.  
  7.  
  8. def doodlestring_herausfilten(doc)
  9. # coding: utf-8
  10. exists = 0
  11. subject = doc.at_css("div#lga") #.at_css("function")#['function'] #"lga" ist eine id
  12.  
  13. subject2 = subject.to_s.split('search?q=')
  14.  
  15. if subject2[1].nil?
  16. subject = "Kein Doodle"
  17. else
  18. querystring_mitplus = subject2[1].split('&')[0] #ct=')[0]
  19. subject = querystring_mitplus.gsub(/\+/, " ")
  20. end
  21. end
  22. def test_google_mit_roentgenstrahlung_crawlen
  23. require 'rubygems'
  24. require 'nokogiri'
  25. require 'open-uri'
  26.  
  27.  
  28. doc = Nokogiri::HTML(File.open("/Users/google-doodle/test/roentgenstrahlung.html"))
  29.  
  30. assert_equal "Röntgenstrahlung", doodlestring_herausfilten(doc)
  31.  
  32. end
  33.  
  34.  
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement