Exemplo n.º 1
0
def parsing():
    users = CWUser.objects.all()
    for user in users:
        last_tasks = parse_url(user.cw_url)
        for task in last_tasks:
            if task in [str(i) for i in user.tasks.all()]:
                pass
            else:
                Tasks.objects.create(name=task, user=user)
Exemplo n.º 2
0
 def post(self):
   url = self.request.get('url')
   playlist_info = memcache.get(url)
   if playlist_info is None:
     playlist_title, playlist_songs = parser.parse_url(url)
     playlist_info = {'title': playlist_title, 'songs': playlist_songs}
     memcache.set(url, simplejson.dumps(playlist_info), 60*60)
   else:
     playlist_info = simplejson.loads(playlist_info)
   self.response.out.write(simplejson.dumps(playlist_info))
Exemplo n.º 3
0
 def post(self):
     url = self.request.get('url')
     playlist_info = memcache.get(url)
     if playlist_info is None:
         playlist_title, playlist_songs = parser.parse_url(url)
         playlist_info = {'title': playlist_title, 'songs': playlist_songs}
         memcache.set(url, simplejson.dumps(playlist_info), 60 * 60)
     else:
         playlist_info = simplejson.loads(playlist_info)
     self.response.out.write(simplejson.dumps(playlist_info))
Exemplo n.º 4
0
 async def receiver(self):
     log.debug("receiver: started!")
     async for msg in self.stream:
         msg = msg.decode("utf-8")
         log.debug(f"received:\n{msg}")
         if msg[0:4] == "PING":
             await self.send("PONG", msg.split()[1])
         else:
             urls = re.findall(URL_REGEX, msg)
             if urls:
                 for url in urls:
                     res = parse_url(url, self.github_token)
                     if res:
                         await self.send("PRIVMSG", f"{self.channel} {res}")
     log.error("receiver: connection closed")
Exemplo n.º 5
0
 def test_example_wikipedia(self):
     u = 'https://en.wikipedia.org/w/index.php?title=John_C._Fr%C3%A9mont&oldid=821454813#Early_life,_education,_and_career'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 6
0
 def test_urls(self):
     for url, result in test_urls.items():
         print(f"url: {url}, result: {result}")
         ref = parse_url(url, github_token)
         self.assertEqual(ref, result)
Exemplo n.º 7
0
def getParser():
    response = parse_url()

    return JSONEncoder().encode({'result': response})
Exemplo n.º 8
0
 def test_example_youtube(self):
     u = 'https://docs.google.com/document/d/1HLAtmHw0OWmrthyO9MDZI7wcs13WxC92H_PNpwrGF2w/edit#heading=h.n76a9i6p9x2f'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 9
0
 def test_example_sso(self):
     u = 'https://login.ualberta.ca/module.php/core/loginuserpass.php?AuthState=_d206496583a0ee5507aded2ee743bce74e885a5610%3Ahttps%3A%2F%2Flogin.ualberta.ca%2Fsaml2%2Fidp%2FSSOService.php%3Fspentityid%3Dhttps%253A%252F%252Feclass.srv.ualberta.ca%252Fsp%26cookieTime%3D1516493628%26RelayState%3Dhttps%253A%252F%252Feclass.srv.ualberta.ca%252Fauth%252Fsaml%252Findex.php%253Fwantsurl%253Dhttps%25253A%25252F%25252Feclass.srv.ualberta.ca%25252F'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 10
0
 def test_example_youtube(self):
     u = 'https://youtu.be/F22Bop-_sxo?t=13s'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 11
0
 def test_example_maps(self):
     u = 'https://www.google.ca/maps/place/West+Edmonton+Mall/@53.5225155,-113.6416984,14z/data=!4m5!3m4!1s0x53a020573a8614db:0x8546a29e09b26fcb!8m2!3d53.5225155!4d-113.6241889'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 12
0
 def test_example_amazon(self):
     u = 'https://www.amazon.ca/Pusheen-Cat-2018-Wall-Calendar/dp/1449484700/ref=sr_1_1?ie=UTF8&qid=1516493370&sr=8-1&keywords=cute+cat+calendar'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 13
0
 def test_example_basic(self):
     u = 'https://www.google.ca/'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 14
0
 def test_example_google(self):
     u = 'https://www.google.ca/search?q=%22cute+cats%22&ie=utf-8&oe=utf-8&gws_rd=cr&dcr=0&ei=_9hjWqm3FpWCjwP3pbjABA'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 15
0
 def test_example_lots_of_percent(self):
     u = 'http://localhost:8080/cats%26scute/index%26shtml?tag=fuzzy&tag=little+pawsies&show=data%26statistics#Statistics%26s'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 16
0
 def test_example_from_assignment(self):
     u = 'http://localhost:8080/cats/cute/index.html?tag=fuzzy&tag=little+pawsies&show=data%26statistics#Statistics'
     self.assertEqual(parser.parse_url(u), self.parse_using_urllib(u))
Exemplo n.º 17
0
 def test_only_scheme(self):
     self.assertEqual(parser.parse_url("about:"),
                      ('about', None, None, None, None, None))