def main():
"""
The entry point for the app. Called when music-scraper is typed in terminal.
Starts the GUI and starts the scraping process after the input is given
"""
curses.initscr()
if curses.COLS < 80 or curses.LINES < 5:
curses.endwin()
print('Terminal\'s dimensions are too small')
return
process = CrawlerProcess({'LOG_ENABLED': False})
def gui_input(screen):
GUI.screen = screen
curses.start_color()
GUI.screen.keypad(1)
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_CYAN)
GUI.high_light_text = curses.color_pair(1)
GUI.normal_text = curses.A_NORMAL
GUI.box = curses.newwin(curses.LINES, curses.COLS, 0, 0)
GUI.message = GUI.get_input()
curses.wrapper(gui_input)
s = request.quote(GUI.message)
MusicSpider.start_urls = [
"http://www.google.com/search?q=" + s,
]
process.crawl(MusicSpider)
thread = GUIThread(process, start_gui)
thread.start()
process.start()
if not GUI.gui_stopped:
if len(GUI.strings) == 0:
GUI.box.erase()
GUI.box.addstr(1, 1, "No Results Found... Try with Some other keywords.", GUI.high_light_text)
GUI.add_bottom_menus()
GUI.screen.refresh()
GUI.box.refresh()
else:
GUI.box.addstr(curses.LINES - 2, 1, "Completed Scraping !!", GUI.high_light_text)
GUI.add_bottom_menus()
GUI.screen.refresh()
GUI.box.refresh()
评论列表
文章目录