Пример #1
0
class TestSite(unittest.TestCase):
    def setUp(self):
        # Point the path to the tor-browser_en-US directory in your system
        tbpath = '/home/kdas/.local/tbb/tor-browser_en-US/'
        self.driver = TorBrowserDriver(tbpath, tbb_logfile_path='test.log')
        self.url = "https://check.torproject.org"

    def tearDown(self):
        # We want the browser to close at the end of each test.
        self.driver.close()

    def test_available(self):
        self.driver.load_url(self.url)
        # Find the element for success
        element = self.driver.find_element_by_class_name('on')
        self.assertEqual(
            str.strip(element.text),
            "Congratulations. This browser is configured to use Tor.")
        sleep(2)  # So that we can see the page
Пример #2
0
# driver.add_cookie({'name': '1P_JAR', 'value': '2019-4-23-3'})
# driver.add_cookie({'name': 'DV', 'value': 'o1Nbl6B8jsZRELXrd6iumDQIQaWCpNYGGjFTFCYbPQAAAOB85pD-5LPtOQAAAOwZ_awmB2dqGAAAAAKrLPZJ7nerCgAAAA'})
# driver.add_cookie({'name': 'SIDCC', 'value': 'AN0-TYsIc9ao8HSl8ErVpCFrEf0JYQbOHu-ttenPp8mfKx-rY-Z6GPOJqgW0snerz0czS1As5w'})

# url = "https://check.torproject.org"
url = "https://www.google.com/search?q=playoffs"

headers = {}
headers["User-agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"


driver.load_url(url)
# driver.context()

# Find the element for success
element = driver.find_element_by_class_name('LC20lb')
print(element)
sleep(2)  # So that we can see the page

driver.close()


# class TestSite(unittest.TestCase):
#     def setUp(self):
#         # Point the path to the tor-browser_en-US directory in your system
#         tbpath = '/home/andrew/Desktop/tor-browser-linux64-8.0.8_en-US/tor-browser_en-US/'
#         self.driver = TorBrowserDriver(tbpath, tbb_logfile_path='test.log', tor_cfg=cm.USE_STEM)
#         self.url = "https://check.torproject.org"

#     def tearDown(self):
#         # We want the browser to close at the end of each test.
Пример #3
0
from tbselenium.tbdriver import TorBrowserDriver
import pickle
from bs4 import BeautifulSoup

tbpath = "tor-browser_en-US"

with open("oniontree-source.html", 'r') as f:
    data = f.read().replace('\n', '')

driver = TorBrowserDriver(tbpath)
# driver.load_url(website)

soup = BeautifulSoup(data, 'html.parser')

anchors = soup.find_all('a')
l = map(lambda x: x.get("href"), anchors)

potential_onions = []

for url in l:
    driver.load_url(url)
    e = driver.find_element_by_class_name("urls")
    onions = e.find_elements_by_tag_name("a")
    if len(onions) > 5:
        print("too many onions for {}. skipping".format(url))
    for o in onions:
        print(o.get_attribute('href'))
        potential_onions.append(o.get_attribute('href'))

pickle.save(potential_onions, 'onions.sav')