我将import requests
from bs4 import BeautifulSoup
import pandas as pd
headings=['Name','Accession Number','Type','Groups','Description'] # add more as needed, first hit on each is taken
df = pd.DataFrame([], columns=headings)
def get_details(url):
global df
global headings
print('details:', url)
r = requests.get(url)
soup = BeautifulSoup(r.text ,"lxml")
dts = soup.findAll('dt')
dds = soup.findAll('dd')
data = {}
for dt, dd in zip(dts, dds):
if (dt.text in headings) and (dt.text not in data):
data[dt.text] = dd.text
df = df.append(data,ignore_index=True)
def drug_data():
url = 'https://www.drugbank.ca/drugs/'
while url:
print(url)
r = requests.get(url)
soup = BeautifulSoup(r.text ,"lxml")
# get links to subpages
links = soup.select('strong a')
for link in links:
# exeecute function to get subpage
get_details('https://www.drugbank.ca' + link['href'])
# next page url
url = soup.findAll('a', {'class': 'page-link', 'rel': 'next'})
print(url)
if url:
url = 'https://www.drugbank.ca' + url[0].get('href')
else:
break
drug_data()
print df[['Name', 'Accession Number']]
应用于.spin
:它正在旋转图标。
该图标已应用<i>
,因此transform
将包含原始.spin
加transform
一个:
第一种方法不起作用,原始rotate
优先。我想知道为什么第二种方法有效?
注意:使用transform
进行编译,因此使用Angular
Shadow Dom Emulation
将其更改为以下作品 - 不确定原因
// SCSS
.menu-button {
i {
transform: translate(-50%, -50%);
}
}
i.spin {
transform: translate(-50%, -50%) rotate(90deg);
}
// CSS Compiled (compiled with Angular, so using Shadow Dom Emulation)
.menu-button[_ngcontent-c4] { }
.menu-button[_ngcontent-c4] i[_ngcontent-c4] {
transform: translate(-50%, -50%);
}
i.spin[_ngcontent-c4] {
transform: translate(-50%, -50%) rotate(90deg);
}
答案 0 :(得分:0)
这与SCSS或Angular没有任何关系,只是与CSS优先级规则有关。
在您的第一种方法中,前一条规则更具体,因此优先于后者。