Why not fire get request Python Vk API?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
Good afternoon. I ask the help in this question, because I don't understand what's going on.

There is a module start_gui.py

from Vk.vk_user import VkMain class GuiMain(Ui_MainWindow): def main(self): self.pushButton_7.clicked.connect(self.init_table_vk) self.pushButton_9.clicked.connect(self.button_clicked_vk) def button_clicked_vk(self): return VkMain() def init_table_vk(self): table_widget = self.tableWidget_3 settings.csv_init(table_widget) if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = GuiMain() ui.setupUi(MainWindow) ui.main() MainWindow.show() sys.exit(app.exec_())


Actually what's important. Function button_clicked_vk. It works as soon as you click on pushButton_7. Works OK and is the correct class at the right module too.

And it calls:

import re import pandas as pd import Vk.vk_friends as friends import Vk.vk_user_groups as user_groups import multiprocessing as multi import numpy as np import sys import Vk.vk_settings as settings from time import sleep class VkMain: def __init__(self): path = Some path settings.path_set(path) cpus = multi.cpu_count() workers = [] id_list = [Some ID List] token_list = settings.token token_bins = self.chunks(cpus, token_list) page_bins = self.chunks(cpus, id_list) for cpu in range(cpus): if cpu > len(id_list) - 1: break sleep(0.2) sys.stdout.write("CPU" + str(cpu) + "\") worker = multi.Process(name=str(cpu), target=self.perform_extraction, args=(page_bins[cpu], token_bins[cpu])) worker.start() workers.append(worker) for worker in workers: worker.join() def perform_extraction(self, page_ranges, token_ranges): reg = re.compile('[^a-zA-Zа-za-z]') fields = 'photo_id, verified, sex, bdate, city, country, home_town, has_photo, photo_50, photo_100, photo_200_orig, photo_200, photo_400_orig, photo_max, photo_max_orig, online, domain, has_mobile, contacts, site, education, universities, schools, status, last_seen, followers_count, common_count, occupation, nickname, relatives, relation, personal, connections, exports, wall_comments, activities, interests, music, movies, tv, books, games, about, quotes, can_post, can_see_all_posts, can_see_audio, can_write_private_message, can_send_friend_request, is_favorite, is_hidden_from_feed, timezone, screen_name, maiden_name, crop_photo, is_friend, friend_status, career, military, blacklisted, blacklisted_by_me' params = { 'user_ids': page_ranges, 'fields': fields, 'name_case': 'Nom', 'v': 5.74, 'access_token': token_ranges } // person_dict attention here person_dict = settings.get_vk_data('https://api.vk.com/method/users.get', params) print(person_dict) ......... // See this method next makes no sense, because print doesn't print out anything. Nothing. def chunks(self, cpu, page_list): return np.array_split(page_list, cpu) if __name__ == '__main__': app = VkMain()


Then I yuzayu multipotent in __init__
In fact it normally comes in a method perform_extraction.
And as I understand it, problema lies in get - request. Because print does not output anything.

Go to our settings, where we take the function responsible for the correct get request.

import time import requests import os.path token = Tokens Some list path = Some path correct def get_vk_data(url, params): // Print nothing prints print(requests.get(url, params=params)) repeat = True while repeat: // Here comes resp = requests.get(url, params=params) data = resp.json() if 'error' in data and 'error_code' in data['error'] and data['error']['error_code'] == 6: print('ERROR') time.sleep(1) else: repeat = False print(data['response']) return data['response']


That came to an end. Here is not working a get request to Vk API. It nothing displays. Even error code.

Please give direction, I don't know what it is.

If you simply call from VkMain class, then everything is OK. Works as it should. But if using guisse, he won't get the query to do.
by | 7 views

1 Answer

0 like 0 dislike
multiprocessing is a problem. Got it, I removed it from the 2 piece of code. As you can normally bypass that and run with Multiprotocol?
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,403 users