Exemplo n.º 1
0
 def test_03_mobile(self):
     """
     測試三立新聞網行動版
     """
     nsoup = NewsSoup(self.url, refresh=True)
     self.assertEqual('setn', nsoup.channel)
     self.assertIn('與母爭吵疑失足墜樓 男子送醫搶救不治', nsoup.title())
     self.assertEqual('2018-02-21 18:03:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('新北市新店區中正路今(21)日下午3時許發生墜樓案件', nsoup.contents())
Exemplo n.º 2
0
 def test_01_sample(self):
     """
     測試中時電子報樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/chinatimes.html.gz', mobile=False)
     self.assertEqual('chinatimes', nsoup.channel)
     self.assertIn('悲慟!北市士林年邁母子 住處上吊自殺身亡', nsoup.title())
     self.assertEqual('2018-09-16 15:31:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('謝明俊', nsoup.author())
     self.assertIn('北市士林區葫蘆街一處民宅', nsoup.contents())
Exemplo n.º 3
0
 def test_02_mobile(self):
     """
     測試中時電子報行動版
     """
     nsoup = NewsSoup(self.url, refresh=True)
     self.assertEqual('chinatimes', nsoup.channel)
     self.assertIn('悲慟!北市士林年邁母子 住處上吊自殺身亡', nsoup.title())
     self.assertEqual('2018-09-16 15:31:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('謝明俊', nsoup.author())
     self.assertIn('北市士林區葫蘆街一處民宅', nsoup.contents())
Exemplo n.º 4
0
 def test_03_mobile(self):
     """
     測試中央社行動版
     """
     nsoup = NewsSoup(self.url, refresh=True, mobile=True)
     self.assertEqual('cna', nsoup.channel)
     self.assertIn('前女友輕生  前男友到殯儀館砍現任還開槍', nsoup.title())
     self.assertEqual('2018-10-17 14:06:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('黃國芳', nsoup.author())
     self.assertIn('民主進步黨籍嘉義市議員王美惠上午到殯儀館參加公祭', nsoup.contents())
Exemplo n.º 5
0
 def test_03_mobile(self):
     """
     測試自由時報行動版
     """
     nsoup = NewsSoup(self.url, refresh=True, mobile=True)
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('疑因病厭世 男子國小圖書館上吊身亡', nsoup.title())
     self.assertEqual('2018-10-15 23:51:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('台北市萬華區的老松國小今(15)日早上驚傳上吊輕生事件', nsoup.contents())
Exemplo n.º 6
0
 def test_01_sample(self):
     """
     測試自由時報樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/ltn.html.gz', mobile=False)
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('10年前父親掐死兒後自縊... 凶宅下月拍開價425萬', nsoup.title())
     self.assertEqual('2018-07-31 08:19:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('台北市萬華區萬大路一帶公寓的蘇姓男子', nsoup.contents())
Exemplo n.º 7
0
 def test_01_sample(self):
     """
     測試中央社樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/cna.html.gz', mobile=False)
     self.assertEqual('cna', nsoup.channel)
     self.assertIn('平鎮輪胎行惡火  疏散7人1女命喪', nsoup.title())
     self.assertEqual('2016-03-19 10:48:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('邱俊欽', nsoup.author())
     self.assertIn('桃園市平鎮區一家輪胎行', nsoup.contents())
Exemplo n.º 8
0
 def test_01_sample(self):
     """
     測試聯合新聞網樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/udn.html.gz', mobile=False)
     self.assertEqual('udn', nsoup.channel)
     self.assertIn('澎湖重度殘障男子 陳屍馬公水仙宮旁空屋', nsoup.title())
     self.assertEqual('2018-02-28 14:31:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('馬公水仙宮旁的一處廢棄破屋內', nsoup.contents())
Exemplo n.º 9
0
 def test_01_sample(self):
     """
     測試三立新聞網樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/setn.html.gz')
     self.assertEqual('setn', nsoup.channel)
     self.assertIn('與母爭吵疑失足墜樓 男子送醫搶救不治', nsoup.title())
     self.assertEqual('2018-02-21 18:03:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('新北市新店區中正路今(21)日下午3時許發生墜樓案件', nsoup.contents())
Exemplo n.º 10
0
 def test_02_mobile(self):
     """
     測試東森新聞雲
     """
     url = 'https://www.ettoday.net/news/20181020/1285826.htm'
     nsoup = NewsSoup(url, refresh=True, proxy_first=True)
     self.assertEqual('ettoday', nsoup.channel)
     self.assertIn('快訊/整日沒出房門!三重無業男半夜住處2樓上吊 母開門才發現', nsoup.title())
     self.assertEqual('2018-10-20 04:11:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('趙永博', nsoup.author())
     self.assertIn('新北市三重區三和路三段101巷一處民宅2樓', nsoup.contents())
Exemplo n.º 11
0
 def test_01_sample(self):
     """
     測試東森新聞雲樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/ettoday.html.gz')
     self.assertEqual('ettoday', nsoup.channel)
     self.assertIn('客運司機車禍致人於死 心情鬱悶陽台以狗鍊上吊', nsoup.title())
     self.assertEqual('2017-12-09 00:26:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('林悅', nsoup.author())
     self.assertIn('台南市永康區永安路住處後陽台上吊', nsoup.contents())
Exemplo n.º 12
0
 def test_02_mobile(self):
     """
     測試自由時報行動版
     """
     url = 'http://news.ltn.com.tw/news/society/breakingnews/2581807'
     nsoup = NewsSoup(url, refresh=True)
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('疑因病厭世 男子國小圖書館上吊身亡', nsoup.title())
     self.assertEqual('2018-10-15 23:51:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('台北市萬華區的老松國小今(15)日早上驚傳上吊輕生事件', nsoup.contents())
Exemplo n.º 13
0
 def test_05_multiple_date_format(self):
     """
     測試多重日期格式
     """
     url = 'https://m.ltn.com.tw/news/politics/paper/1249335'
     nsoup = NewsSoup(url, refresh=True)
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('狂拿15席 吳總教頭首戰告捷', nsoup.title())
     self.assertEqual('2018-11-25 00:00:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('施曉光', nsoup.author())
     self.assertIn('由黨魁吳敦義扮演「總教頭」並宣稱要擊出二十二支全壘打的國民黨', nsoup.contents())
Exemplo n.º 14
0
 def test_04_switch_mobile(self):
     """
     測試自動切換行動版
     """
     url = 'http://sports.ltn.com.tw/news/breakingnews/2626821'
     nsoup = NewsSoup(url, refresh=True)
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('MLB》王牌陣解體在即?印地安人傳更想出售鮑爾', nsoup.title())
     self.assertEqual('2018-11-28 14:21:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('鮑爾目前只剩兩年控制權,而他今年有望靠著優異表現在薪資上大幅躍進', nsoup.contents())
Exemplo n.º 15
0
 def test_01_sample(self):
     """
     測試中時電子報樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/chinatimes.html.xz')
     self.assertEqual('chinatimes', nsoup.channel)
     self.assertIn('悲慟!北市士林年邁母子 住處上吊自殺身亡', nsoup.title())
     self.assertEqual('2018-09-16 15:31:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('謝明俊', nsoup.author())
     self.assertIn('北市士林區葫蘆街一處民宅', nsoup.contents())
Exemplo n.º 16
0
 def test_01_sample(self):
     """
     測試本地樣本解構
     * 如果測試 02 失敗,需要用 bin/getnews.sh 重新製作本地樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/appledaily.html.gz', mobile=False)
     self.assertEqual('appledaily', nsoup.channel)
     self.assertIn('和男友口角鎖門吞藥 女墜樓不治', nsoup.title())
     self.assertEqual('2016-05-21 11:44:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('王煌忠', nsoup.author())
     self.assertIn('文心路的一棟住宅大樓', nsoup.contents())
Exemplo n.º 17
0
 def test_03_mobile(self):
     """
     測試東森新聞雲行動版
     """
     nsoup = NewsSoup(self.url, refresh=True)
     self.assertEqual('ettoday', nsoup.channel)
     self.assertIn('快訊/整日沒出房門!三重無業男半夜住處2樓上吊 母開門才發現', nsoup.title())
     self.assertEqual('2018-10-20 04:11:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual('趙永博', nsoup.author())
     self.assertIn('新北市三重區三和路三段101巷一處民宅2樓', nsoup.contents())
Exemplo n.º 18
0
 def test_01_sample(self):
     """
     測試本地樣本解構
     * 如果測試 02 失敗,需要用 bin/getnews.sh 重新製作本地樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/cna.html.gz', mobile=False)
     self.assertEqual('cna', nsoup.channel)
     self.assertIn('平鎮輪胎行惡火  疏散7人1女命喪', nsoup.title())
     self.assertEqual('2016-03-19 10:48:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('桃園市平鎮區一家輪胎行', nsoup.contents())
Exemplo n.º 19
0
 def test_02_mobile(self):
     """
     測試聯合新聞網行動版
     """
     nsoup = NewsSoup(self.url, refresh=True)
     self.assertEqual('udn', nsoup.channel)
     self.assertIn('清晨起床發現父親上吊天花板 嚇壞女兒急報案', nsoup.title())
     self.assertEqual('2018-10-06 15:45:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual('陳宏睿', nsoup.author())
     self.assertIn('台中市北區水源街', nsoup.contents())
Exemplo n.º 20
0
 def test_03_mobile(self):
     """
     測試蘋果日報行動版
     """
     nsoup = NewsSoup(self.url, refresh=True)
     self.assertEqual('appledaily', nsoup.channel)
     self.assertIn('男子疑久病厭世 學校圍牆上吊輕生亡', nsoup.title())
     self.assertEqual('2018-10-25 12:03:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual('江宏倫', nsoup.author())
     self.assertIn('台北市北投區西安街二段', nsoup.contents())
Exemplo n.º 21
0
 def test_02_mobile(self):
     """
     測試蘋果日報行動版
     """
     url = 'https://tw.news.appledaily.com/local/realtime/20181025/1453825'
     nsoup = NewsSoup(url, refresh=True)
     self.assertEqual('appledaily', nsoup.channel)
     self.assertIn('男子疑久病厭世 學校圍牆上吊輕生亡', nsoup.title())
     self.assertEqual('2018-10-25 12:03:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('江宏倫', nsoup.author())
     self.assertIn('台北市北投區西安街二段', nsoup.contents())
Exemplo n.º 22
0
 def test_01_sample(self):
     """
     測試蘋果日報樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/appledaily.html.gz')
     self.assertEqual('appledaily', nsoup.channel)
     self.assertIn('和男友口角鎖門吞藥 女墜樓不治', nsoup.title())
     self.assertEqual('2016-05-21 11:44:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('王煌忠', nsoup.author())
     self.assertIn('文心路的一棟住宅大樓', nsoup.contents())
Exemplo n.º 23
0
 def test_03_mobile(self):
     """
     測試行動版網頁解構
     * 務必開啟強制更新,確保解構程式能跟進網站最新版本
     * 實際新聞內容有可能更新,需要同步單元測試的預期值
     """
     nsoup = NewsSoup(self.url, refresh=True, mobile=True)
     self.assertEqual('cna', nsoup.channel)
     self.assertIn('前女友輕生  前男友到殯儀館砍現任還開槍', nsoup.title())
     self.assertEqual('2018-10-17 14:06:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('民主進步黨籍嘉義市議員王美惠上午到殯儀館參加公祭', nsoup.contents())
Exemplo n.º 24
0
 def test_01_sample(self):
     """
     測試聯合新聞網樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/udn.html.xz')
     self.assertEqual('udn', nsoup.channel)
     self.assertIn('血濺桃機 他把老婆丟下樓再跳樓', nsoup.title())
     self.assertEqual('2019-03-18 23:59:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual('陳嘉寧', nsoup.author())
     self.assertIn('萬與張女站在第二航廈出境大廳管制區外南側四樓往三樓樓梯迴轉處爭吵', nsoup.contents())
Exemplo n.º 25
0
 def test_03_mobile(self):
     """
     測試行動版網頁解構
     * 務必開啟強制更新,確保解構程式能跟進網站最新版本
     * 實際新聞內容有可能更新,需要同步單元測試的預期值
     """
     nsoup = NewsSoup(self.url, refresh=True, mobile=True)
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('疑因病厭世 男子國小圖書館上吊身亡', nsoup.title())
     self.assertEqual('2018-10-15 23:51:00', nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('台北市萬華區的老松國小今(15)日早上驚傳上吊輕生事件', nsoup.contents())
Exemplo n.º 26
0
 def test_01_sample(self):
     """
     測試自由時報樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/ltn.html.xz')
     self.assertEqual('ltn', nsoup.channel)
     self.assertIn('10年前父親掐死兒後自縊... 凶宅下月拍開價425萬', nsoup.title())
     self.assertEqual('2018-07-31 08:19:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual(None, nsoup.author())
     self.assertIn('台北市萬華區萬大路一帶公寓的蘇姓男子', nsoup.contents())
Exemplo n.º 27
0
 def test_01_sample(self):
     """
     測試中央社樣本
     """
     pkgdir = twnews.common.get_package_dir()
     nsoup = NewsSoup(pkgdir + '/samples/cna.html.xz')
     self.assertEqual('cna', nsoup.channel)
     self.assertIn('平鎮輪胎行惡火  疏散7人1女命喪', nsoup.title())
     self.assertEqual('2016-03-19 10:48:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual('邱俊欽', nsoup.author())
     self.assertIn('桃園市平鎮區一家輪胎行', nsoup.contents())
Exemplo n.º 28
0
 def test_06_http_redirect(self):
     """
     測試轉址效果
     """
     url = 'https://news.ltn.com.tw/news/entertainment/breakingnews/2697368'
     nsoup = NewsSoup(url, refresh=True)
     self.assertEqual('ltn', nsoup.channel)
     self.assertEqual('https://ent.ltn.com.tw/m/news/breakingnews/2697368', nsoup.path)
     self.assertIn('摸胸夾腿都來!邵翔小蠻交往6年公布「有了」', nsoup.title())
     self.assertEqual('2019-02-13 11:46:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('蕭宇涵', nsoup.author())
     self.assertIn('小蠻一席黑色小禮服大露蜜腿,雙手游移挑逗扒開邵翔的襯衫', nsoup.contents())
Exemplo n.º 29
0
 def test_01_sample(self):
     """
     測試本地樣本解構
     * 如果測試 02 失敗,需要用 bin/getnews.sh 重新製作本地樣本
     """
     nsoup = NewsSoup(pkgdir + '/samples/setn.html.gz', mobile=False)
     self.assertEqual('setn', nsoup.channel)
     self.assertIn('與母爭吵疑失足墜樓 男子送醫搶救不治', nsoup.title())
     self.assertEqual('2018-02-21 18:03:00',
                      nsoup.date().strftime(self.dtf))
     self.assertEqual('', nsoup.author())
     self.assertIn('新北市新店區中正路今(21)日下午3時許發生墜樓案件', nsoup.contents())
Exemplo n.º 30
0
 def test_03_mobile(self):
     """
     測試行動版網頁解構
     * 務必開啟強制更新,確保解構程式能跟進網站最新版本
     * 實際新聞內容有可能更新,需要同步單元測試的預期值
     """
     nsoup = NewsSoup(self.url, refresh=True, mobile=True)
     self.assertEqual('appledaily', nsoup.channel)
     self.assertIn('男子疑久病厭世 學校圍牆上吊輕生亡', nsoup.title())
     self.assertEqual('2018-10-25 12:03:00', nsoup.date().strftime(self.dtf))
     self.assertEqual('江宏倫', nsoup.author())
     self.assertIn('台北市北投區西安街二段', nsoup.contents())