コード例 #1
0
 def search(self, query):
     headers = {
         'user-agent':
         'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.46 Safari/537.36'
     }
     first_time = helpers.soupify(
         helpers.get('https://twist.moe',
                     allow_redirects=True,
                     headers=headers))
     js = first_time.select_one('script').text
     js = "location = {'reload': ()=>true};document = {}; \n" + js + f"console.log(document.cookie)"
     cookie = eval_in_node(js).strip()
     with requests_cache.disabled():
         headers['cookie'] = cookie
         r = requests.get('https://twist.moe/', headers=headers)
         soup = helpers.soupify(r)
     all_anime = soup.select_one('nav.series').select('li')
     animes = []
     for anime in all_anime:
         animes.append(
             SearchResult(
                 title=anime.find('span').contents[0].strip(),
                 url='https://twist.moe' + anime.find('a')['href'],
             ))
     animes = [ani[0] for ani in process.extract(query, animes)]
     return animes
コード例 #2
0
    def _get_data(self):
        url = self.url

        res = helpers.get(url)
        js = re.findall(r'<script type="text/javascript">([^"]+)var srces',
                        res.text)[0]
        src = re.findall(r'src:d\(([^"]+?)\)', res.text)[0]
        js = "window = {}; \n" + js + f"console.log(window.d({src}))"
        logger.debug(f"Evaling: {js}")
        output = eval_in_node(js)
        stream = "https:" + output
        return {
            'stream_url': stream,
        }
コード例 #3
0
def get_cookie(soup):
    js = soup.select_one('script').text
    js = "location = {'reload': ()=>true};document = {}; \n" + js + f"console.log(document.cookie)"
    cookie = eval_in_node(js).strip()
    return cookie