def test_check_path_given_invalid_path(self): path = "C:\\useraccount\\documents\\pictures\\subdirectory\\subdirectory\\subdirectory\\" \ "subdirectory\\subdirectory\\subdirectory\\subdirectory\\subdirectory\\subdirectory\\" \ "subdirectory\\subdirectory\\subdirectory\\subdirectory\\subdirectory\\subdirectory\\" \ "subdirectory\\subdirectory\\subdirectory\\subdirectory\\subdirectory\\subdirectory\\.jpg" self.assertFalse(check_path(path))
import crawler as cl import requests from bs4 import BeautifulSoup page_count = 21 attemp_url__ff = "" + str(page_count) directory_path = "./photo/" cl.check_path(directory_path) def main(page_url, page_count): count = 1 page = cl.Crawl(page_url) page.link = [] page.parse_aTags("div.thread-item a") page.set_link("", "") for i in page.link: if (i == "https://www.pttweb.cc/bbs/Gossiping"): continue post = cl.Crawl(i) post.link = [] post.parse_aTags("a.externalHref") post.set_link("", "") print(post.link) for t in post.link: if ("i.imgur.com" not in t): continue if (".gif" in t): continue
def test_check_path_given_valid_path(self): path = "C:\\useraccount\\documents\\pictures\\picture1.jpg" self.assertTrue(check_path(path))