我想从网站http://www.x-rates.com/table/?from=USD&amount=1(它是货币兑换网站)废弃数据.
我想从表中得到"欧元"字样,但我得到空列表.这是我的代码:
from bs4 import BeautifulSoup
import requests
res = requests.get('http://www.x-rates.com/table/?from=USD&amount=1')
soup = bs4.BeautifulSoup(res.text, 'html.parser')
hehe = soup.select('table.ratesTable:nth-child(4) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1)')
print hehe
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
hehe = soup.select('table.ratesTable + table.ratesTable + table.ratesTable + table.ratesTable table.ratesTable + tbody + tbody + tbody + tr + tr + td + td')
Run Code Online (Sandbox Code Playgroud)
但仍然没有.我应该改变什么?
嗨,我有一个问题,比如主题标题。
我有我的世界详细信息 - 这里我有这个世界上的国家列表。我想只从这个世界删除一个国家,而不是一般的,然后自动返回这个世界。
查看我的世界:
def my_world(request, pk):
world = get_object_or_404(World, pk=pk)
return render(request, 'game/my_world.html', {'world': world})
def delete_country(request, world_pk, country_pk):
world = get_object_or_404(World, pk=pk)
country = get_object_or_404(Country, pk=pk)
world.country.remove(country)
return redirect("my_world", pk=world.pk)
Run Code Online (Sandbox Code Playgroud)
错误说它是关于线的
world = get_object_or_404(World, pk=pk)
Run Code Online (Sandbox Code Playgroud)
在模板中
{% url 'game.views.delete_country' world_pk=world.pk country_pk=country.pk %}
Run Code Online (Sandbox Code Playgroud)
网址.py
url(r'^world/(?P<world_pk>\d+)/(?P<country_pk>\d+)/$', views.delete_country, name='delete_country'),
Run Code Online (Sandbox Code Playgroud)
模型.py
class Country(models.Model):
name = models.CharField(verbose_name="Name of country", max_length=100, default="Australia")
number = models.IntegerField(verbose_name="number of country", default="1")
def __unicode__(self):
return self.name
class World(models.Model):
country = models.ManyToManyField(Country)
name = models.CharField(verbose_name="New Map", max_length=100)
def …Run Code Online (Sandbox Code Playgroud)