Category : url

I need help with my code. For information I use Selenium with python elems = driver.find_element_by_xpath("//article[@class=’page-container’]/section/div[3]") for job in elems: job_list.append(job.get_attribute(‘href’)) print(job_list) The error is "TypeError: ‘WebElement’ object is not iterable". I know that the result of elems is a WebElement, but I need to use find_element_by_xpath because I want a specific div and this ..

Read more

Right now I have my urls.py set up like this: urlpatterns = [ … path(‘dividends/<str:month>/’, views.DividendView.as_view(), name=’dividendview’), path(‘dividends/’, views.DividendView.as_view(), name=’dividendview’), ] What I would like is to have the ‘month’ parameter optional and default to today’s month. Right now I have my views.py set up as class DividendView(ListView): model = Transaction template_name = ‘por/dividends.html’ def ..

Read more

I’ve been using code python to access to this kind of url https://api.elsevier.com/analytics/scival/institution/metrics?metricTypes=ScholarlyOutput&institutionIds=508175%2C508076&yearRange=5yrs&includeSelfCitations=true&byYear=true&includedDocs=AllPublicationTypes&journalImpactType=CiteScore&showAsFieldWeighted=false&apiKey=7f59af901d2d86f78a1fd60c1bf9426a This is a public json url given by Elsevier Developer Portal The little code I’ve been using is this: import requests import json url = "https://api.elsevier.com/analytics/scival/institution/metrics?metricTypes=ScholarlyOutput&institutionIds=508175%2C508076&yearRange=5yrs&includeSelfCitations=true&byYear=true&includedDocs=AllPublicationTypes&journalImpactType=CiteScore&showAsFieldWeighted=false&apiKey=7f59af901d2d86f78a1fd60c1bf9426a" with requests.Session() as s: data = s.get(url).json() Everything was ok until today that my project gives ..

Read more

I have two models: class Book(models.Model): id = models.CharField(verbose_name="unique id", primary_key=True, max_length=256) title = models.CharField(max_length=256) published_date = models.CharField(max_length=128, blank=True, null=True) average_rating = models.IntegerField(blank=True, null=True, default=None) ratings_count = models.IntegerField(blank=True, null=True, default=None) thumbnail = models.URLField(verbose_name="thumbnail url", null=True, blank=True, default=None) class Author(models.Model): name = models.CharField(null=True, blank=True, max_length=256) books = models.ManyToManyField(Book, related_name=’authors’) What i want to achieve is that ..

Read more

I’m studying DRF through realworld github. I got some problem about validation. Using python(3.8.0), django(3.2.8), drf(3.12.4), Postman. I’m trying to update "image_url" through Postman request. But my serializer cannot receive "image_url". I think that "image_url" does not pass validation.. before update serializer.. because when I printed "serializer_data", I was able to take "image_url" like first ..

Read more

I am writing a function to generate an API url which accept multiple arguments and replicates a part of the string. The short version(which only accept one value for variable Val) looks like this def get_url(par,att,value, _filter): base_url=”’https://mytest.com/api/Test/”’+str(par)+”’?size=100000&filters=[”’ url = base_url + ”'{"VarA" : "”’+att+”’", "Val":["”’+value+”’"], "VarB":"”’+_filter+”’"}]”’ return url print(get_url(‘Sales’,{‘Year’:[‘2020’] , "Time"})) This will return ..

Read more

I am a beginner and need a little support. Everything works in the application, but when in the form it typing "new york", "_" is missing in the url. My code is res = urllib.request.urlopen(f’http://api.openweathermap.org/data/2.5/weather?q={city}&appid=1b79ea7b1251b7a830b41a81d6bd’).read() In response receives " InvalidURL at / URL can’t contain control characters. ‘/data/2.5/weather?q=bielsko biala&appid=1b79ea7b1251b76cc0b41a81d6bd’ (found at least ‘ ‘) I ..

Read more