def get_capabilities(self, zone): """See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/getNomenclatureRFU_get_0` """ url = urljoin(self.base_url, r"rfuoge/getcapabilities") return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw, params={r"zone": zone})
def get_my_capabilities(self): """See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/getCapaKey_get_1` """ url = urljoin(self.base_url, r"rfuoge/getmycapabilities") return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw)
def referentielsoge_ge(self): """"See.. `https://api.geofoncier.fr/documentation/#!/referentielsoge/getInfoGE_get_2` """ url = urljoin(self.base_url, r"referentielsoge/ge") return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw, params={r"numero": self.user})
def edit(self, zone, data): """"See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/editRFU_post_7` """ url = urljoin(self.base_url, r"rfuoge/edit") return tools.request( url, user_agent=self.user_agent, user=self.user, password=self.pw, params={r"zone": zone}, data={r"xml": data})
def dossiersoge_dossiers(self, zone, enr_ref_dossier): """"See.. `https://api.geofoncier.fr/documentation/#!/dossiersoge/getDossiers_get_5` """ url = urljoin(self.base_url, r"dossiersoge/dossiers") return tools.request( url, user_agent=self.user_agent, user=self.user, password=self.pw, params={r"zone": zone, r"enr_ref_dossier": enr_ref_dossier})
def extraction(self, xmin, ymin, xmax, ymax): """See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/extractRFU_get_2` """ url = urljoin(self.base_url, r"rfuoge/extraction") return tools.request( url, user_agent=self.user_agent, user=self.user, password=self.pw, params={r"bbox": r"%s,%s,%s,%s" % (xmin, ymin, xmax, ymax)})
def get_each_aid_page_num(self, space_id): for aid in self.get_video_aid(space_id): url = 'https://www.bilibili.com/video/av{aid}'.format(aid=aid) con = request(url, header=base_header) if con: page_num_pattern = '{aid},\"videos\":(\d+)'.format(aid=aid) page = re.findall(page_num_pattern, con.content) if page: page = int(page[0]) yield page, aid
def edit(self, zone, data): """"See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/editRFU_post_7` """ url = urljoin(self.base_url, r"rfuoge/edit") return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw, params={r"zone": zone}, data={r"xml": data})
def get_video_aid(self, space_id): pages_num_url = "http://space.bilibili.com/ajax/member/getSubmitVideos?mid={space_id}&pagesize=30&tid=0&page=1&keyword=&order=senddate".format( space_id=space_id) con = request(pages_num_url, header=base_header) if con: try: pages_num = int(con.json()["data"]["pages"]) except Exception, e: print 'IN get_video_aid ' print e else: for i in range(1, pages_num): url = "http://space.bilibili.com/ajax/member/getSubmitVideos?mid={space_id}&pagesize=30&tid=0&page=1&keyword=&order=senddate".format( space_id=space_id) html_json = request(url, header=base_header) video_json_list = html_json.json() for data in video_json_list.get('data').get('vlist'): yield data.get('aid')
def get_title_and_each_page_cid(self, space_ids): for space_id in space_ids: for i, aid in self.get_each_aid_page_num(space_id): page_num = i + 1 for j in range(1, page_num): url = 'http://api.bilibili.com/view?type=jsonp&appkey=8e9fc618fbd41e28&id={aid}&page={page}'.format( aid=aid, page=j) con = request(url, header=base_header) if con: content = con.json() title = content.get('title').replace('/', '_') partname = content.get('list').get('0').get('part') cid = content.get('list').get('0').get('cid') # 创建文件夹 if not os.path.exists(title): os.mkdir(title) # get download_url page_url = 'https://www.bilibili.com/video/av{aid}/?p={page}'.format( aid=aid, page=j) download_api_url = self.get_video_download_api_url(cid) download_content = request(download_api_url, header=None).json() durl = download_content.get('durl') if durl: for data in durl: order = data.get('order') true_video_url = data.get('url') save_name = str( j) + '_' + partname + '_' + str( order) + '.flv' pwd = os.path.join( os.path.join(os.getcwd(), title), save_name) video_url_queue.put( (pwd, true_video_url, page_url))
def dossiersoge_dossiers(self, zone, enr_ref_dossier): """"See.. `https://api.geofoncier.fr/documentation/#!/dossiersoge/getDossiers_get_5` """ url = urljoin(self.base_url, r"dossiersoge/dossiers") return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw, params={ r"zone": zone, r"enr_ref_dossier": enr_ref_dossier })
def close_changeset(self, zone, id): """"See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/closeChangeset_put_6` """ if zone == r"mayotte": zone = "y" url = urljoin(self.base_url, r"rfuoge/changeset/%s%s" % (zone[0], id)) return tools.request( url, user_agent=self.user_agent, user=self.user, password=self.pw, method=r"PUT", params={r"request": r"close", "id_changeset": id})
def open_changeset(self, zone, enr_api_dossier=None, commentaire=None, data={}): """"See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/createChangeset_post_5` """ params={r"zone": zone} if enr_api_dossier: params[r"enr_api_dossier"] = enr_api_dossier if commentaire: params[r"commentaire"] = commentaire url = urljoin(self.base_url, r"rfuoge/changeset") return tools.request( url, user_agent=self.user_agent, user=self.user, password=self.pw, params=params, data=data)
def close_changeset(self, zone, id): """"See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/closeChangeset_put_6` """ if zone == r"mayotte": zone = "y" url = urljoin(self.base_url, r"rfuoge/changeset/%s%s" % (zone[0], id)) return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw, method=r"PUT", params={ r"request": r"close", "id_changeset": id })
def open_changeset(self, zone, enr_api_dossier=None, commentaire=None, data={}): """"See.. `https://api.geofoncier.fr/documentation/#!/rfuoge/createChangeset_post_5` """ params = {r"zone": zone} if enr_api_dossier: params[r"enr_api_dossier"] = enr_api_dossier if commentaire: params[r"commentaire"] = commentaire url = urljoin(self.base_url, r"rfuoge/changeset") return tools.request(url, user_agent=self.user_agent, user=self.user, password=self.pw, params=params, data=data)