![]() |
unusual error in printing result - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: unusual error in printing result (/thread-19874.html) |
unusual error in printing result - janaki26794 - Jul-17-2019 I want to print the names of the people in the url with which it is capturing from the webpage from another python file.This is how I have provided the defination of the class which I am not supposed to change datatracker.py def people(self, since="1970-01-01T00:00:00", until="2038-01-19T03:14:07", name_contains=None): """ A generator that returns people recorded in the datatracker. As of April 2018, there are approximately 21500 people recorded. Parameters: since -- Only return people with timestamp after this until -- Only return people with timestamp before this name_contains -- Only return peopls whose name containing this string Returns: An iterator, where each element is as returned by the person() method """ url = self.base_url + "/api/v1/person/person/?time__gt=" + since + "&time__lt=" + until if name_contains is not None: url = url + "&name__contains=" + name_contains while url is not None: r = self.session.get(url, verify=True) meta = r.json()['meta'] objs = r.json()['objects'] url = meta['next'] for obj in objs: yield objThe person class is as shown below: @dataclass class Person: resource_uri: str id: int name: str name_from_draft: str ascii: str ascii_short: Optional[str] user: str time: str photo: str photo_thumb: str biography: str consent: boolI have to write another python code which would call this function and give me the names of the people I tried writing the code to print the result in another python file as shown below, but it threw an error although I was able to get the names app.py import requests import datatracker import rfcindex user=datatracker.DataTracker() user_people = user.people("1970-01-01T00:00:00", "2038-01-19T03:14:07", "") for u in user_people: print(u['name'])raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '/api/v1/person/person/?limit=20&name__contains=&time__gt=2010-01-01&time__lt=2020-01-01&offset=20': No schema supplied. Perhaps you meant http:///api/v1/person/person/?limit=20&name__contains=&time__gt=2010-01-01&time__lt=2020-01-01&offset=20? Please help RE: unusual error in printing result - nilamo - Jul-18-2019 (Jul-17-2019, 10:20 PM)janaki26794 Wrote:url = self.base_url + "/api/v1/person/person/?time__gt=" + since + "&time__lt=" + until (Jul-17-2019, 10:20 PM)janaki26794 Wrote: Looks like self.base_url doesn't have a value.
|