您可以使用WebDriver仿真浏览,也可以像这样调用GraphQl API:
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'x-gql-country': 'US',
'x-gql-access-token': '7422fb01-fe49-11ec-b208-a93cbb385750',
'x-gql-guid': 'GA1.2.1984313165.1657235201',
'x-gql-language': 'en',
'x-gql-operation-name': 'CategoryProductSearch',
'Origin': 'https://www.sigmaaldrich.com',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'Referer': 'https://www.sigmaaldrich.com/US/en/products/materials-science/biomedical-materials/polymerization-tools?country=GB&language=en&cmsRoute=products&cmsRoute=materials-science&cmsRoute=biomedical-materials&cmsRoute=polymerization-tools&page=1%22%27',
'Connection': 'keep-alive',
}
json_data = {
'operationName': 'CategoryProductSearch',
'variables': {
'searchTerm': None,
'page': 1,
'perPage': 20,
'sort': 'relevance',
'selectedFacets': [
{
'key': 'facet_web_product_area',
'options': [
'S281',
],
},
],
'facetSet': [
'facet_product_category',
'facet_web_polymer_arch_functionality',
'facet_web_polymer_arch_shape',
'facet_fwght',
'facet_web_greener_alternative_principles',
'facet_web_markush-class',
'facet_web_markush-group',
'facet_melting_point',
'facet_physical_form',
'facet_web_react_suitability_reagent_type',
'facet_brand',
],
},
'query': 'query CategoryProductSearch($searchTerm: String, $page: Int!, $perPage: Int!, $sort: Sort, $selectedFacets: [FacetInput!], $facetSet: [String]) {\n getProductSearchResults(input: {searchTerm: $searchTerm, pagination: {page: $page, perPage: $perPage}, sort: $sort, group: product, facets: $selectedFacets, facetSet: $facetSet}) {\n ...CategoryProductSearchFields\n __typename\n }\n}\n\nfragment CategoryProductSearchFields on ProductSearchResults {\n metadata {\n itemCount\n page\n perPage\n numPages\n __typename\n }\n items {\n ... on Product {\n ...CategorySubstanceProductFields\n __typename\n }\n __typename\n }\n facets {\n key\n numToDisplay\n isHidden\n isCollapsed\n multiSelect\n prefix\n options {\n value\n count\n __typename\n }\n __typename\n }\n __typename\n}\n\nfragment CategorySubstanceProductFields on Product {\n name\n productNumber\n productKey\n isMarketplace\n marketplaceOfferId\n marketplaceSellerId\n attributes {\n key\n label\n values\n __typename\n }\n brand {\n key\n erpKey\n name\n color\n __typename\n }\n images {\n altText\n smallUrl\n mediumUrl\n largeUrl\n __typename\n }\n description\n paMessage\n __typename\n}\n',
}
response = requests.post('https://www.sigmaaldrich.com/api', headers=headers, json=json_data)
data = response.json()
您可能不需要所有的标头键,有些键可能在一段时间后可能不会有效。但这将为您提供所需内容的数据对象。
一旦有了指向化合物的链接:
可能有更好的方法来做到这一点...
import requests
from bs4 import BeautifulSoup
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'DNT': '1',
'Upgrade-Insecure-Requests': '1',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Connection': 'keep-alive',
}
response = requests.get('https://www.sigmaaldrich.com/US/en/product/aldrich/o7805', headers=headers)
sp = BeautifulSoup(response.text)
#find the data script
str_data = sp.find('script',{'id':'__NEXT_DATA__'}).text
#assign values so eval works correctly
false = False
true = True
null = None
#evaluate the string to python dict
d = eval(str_data)
#take what you need
cas = d['props']['pageProps']['data']['getProductDetail']['casNumber']
attrs = d['props']['pageProps']['data']['getProductDetail']['attributes']
smiles = [attr_d['values'] for attr_d in attrs if attr_d['key']=='smiles string']
print(cas,smiles)
输出:
112-90-3 [['[H]\\C(CCCCCCCC)=C(/[H])CCCCCCCCN']]
似乎可以通过在我的答案中使用相同的逻辑来解决此处的问题 - 关于路线匹配的匹配 - 限制 - cartitems-app”>问题。它并未明确称为问题或其他需要解决/固定的(,我以为您想您使用过代码,并且在其他地方遇到了一个问题),因此在此处为特定的Axios问题和解决方案添加答案。
看起来像导航到“/cart”
将导致 productid 和
QTY
是未定义/无效的值,useffect
挂钩无条件地派遣操作以添加项目&数量。 productid
在axios.get(`/products/$ {productid}`)
中未定义。
如果有有效的产品ID和要添加的数量,则只能派遣addtocart
操作。
const CartScreen = () => {
const { search } = useLocation();
const { productid } = useParams();
const qty = search ? Number(search.split('=')[1]) : 1;
const dispatch = useDispatch();
const cart = useSelector((state) => state.cart);
const { cartItems } = cart;
useEffect(() => {
if (productid && qty > 0) {
dispatch(addToCart(productid, qty)); // <-- only dispatch if valid
}
}, [dispatch, productid, qty]);
return (
<Row>
<Col md={8}>
{!cartItems.length
? (
<Message variant="info">
<Link to="/">
Go Back To Home Page
</Link>
</Message>
) : (
<ListGroup>
{cartItems.map((x) => (
<ListGroup.Item key={x.product}>
{x.name} , {x.qty}
</ListGroup.Item>
))}
</ListGroup>
)
}
</Col>
<Col md={4}></Col>
</Row>
);
};
您可以将步骤流到以下
- 1.更改str(word)以列出str(字母)
- 2。使用循环检查并更改列表中的str(字母)一一乘
- 3.MERGE列表oft str(字母)到str(word)
代码 :
word = list(word)
for position in range(len(word)):
letter = word[position]
if letter == 'i':
word[position] = '1'
''.join(word)
如果您不了解简单的英语写的内容,则应该花一些时间来学习这种语言,即 https:https:https:https: //www.duolingo.com/ 是一个不错的选择
如果您不了终极线程组文档和支持材料:
等效的终极线程组配置将是:
#EACH_WITH_OBJECT
方法在这里可能很有用。在这种情况下,我们将传递h
,该哈希在array
中为每个元素更新。然后由#EACH_WITH_OBJECT
方法返回哈希。
注意:|| =
如果左侧侧为nil
或false
,则将右侧分配给左侧。
array.each_with_object({}) { |x, h| (h[x[:ID]] ||= {}).update(x) }
收益率:
{"aaa"=>{"ID"=>"aaa", "step3"=>70, "step1"=>160, "step2"=>80},
"bbb"=>{"ID"=>"bbb", "step1"=>80}}
然后,我们只需要使用#values
即可获取我们想要的数据。
array
.each_with_object({}) { |x, h| (h[x[:ID]] ||= {}).update(x) }
.values
收益率:
[{"ID"=>"aaa", "step3"=>70, "step1"=>160, "step2"=>80},
{"ID"=>"bbb", "step1"=>80}]
但是您希望缺少用0
填充的密钥。为此,我们必须知道所有密钥是什么,然后我们可以再次使用#each_with_object
。
grouped = array
.each_with_object({}) { |x, h| (h[x[:ID]] ||= {}).update(x) }
.values
all_keys = grouped.map(&:keys).flatten.uniq
grouped.map! { |h| all_keys.each_with_object(h) { |k, _h| _h[k] ||= 0 } }
现在分组
是:
[{"ID"=>"aaa", "step2"=>80, "step1"=>160, "step3"=>70},
{"ID"=>"bbb", "step1"=>80, "step2"=>0, "step3"=>0}]
对我来说,似乎我只需要在&lt; script&gt;
标记中指定lang
属性为“ ts”
。
<script>
...
</script>
到
<script lang="ts">
...
</script>
因此,这是我阅读以下问题的方式:
开销位是不计入被缓存的实际数据的位。&nbsp;它们是跟踪缓存的维护状态的位,并帮助缓存命中,写回和驱逐策略。&nbsp;以某种方式查看它,如果一个字节被缓存(8位)在缓存中有多少个非数据位,以帮助管理它(或至少对于所有实际数据位在那里)。
这是数学上的,所以我希望我没有犯错,但是即使我也许您可以通过推理看待自己的方式。
让我们获取一些其他信息:
写下策略意味着缓存需要为每个数据块存储“脏”信息:肮脏是1位:是的,肮脏的-or-否,清洁。
对于2向套件的关联缓存,“完美” LRU算法也是1位(是:第一个块-or-否:第二块),但是每个索引位置的1位成本(即每行) - 不是每个块是每个索引两个块。
我们不知道是否有一个有效的位,这也是每个数据块,但是我在课程中看到的大多数缓存都有有效的位,因此我们可能会假设他们拥有它。
最后,有标签位的标签位:但是,在考虑索引位和块偏移位后,地址空间位剩下许多位。
因此,开销的公式可能是:
位于位的开销=索引位置 *(1 x lru bit + block开销位),
其中块上的头顶位= 2 [方式]
我们还知道标签位=地址空间位 - 索引位 - 块位
,因此我们有:
4352 [bits in bits in Bits] =索引位置 *(1 + 2 *(2 + tag lits))
- 和 -
tag bits =地址空间位 - 索引位 - 块偏移位
- 和 -
索引位置= 2 索引位
- 和 -
我们还知道,标签,索引和块偏移位的数量必须是一个整数(无位分数)。
因此,我们可以通过替换来开始减少这两个公式:
4352 =索引位置 *(1 + 2 *(2 +地址空间位 - 索引位 - 索引位 - 块位 - 块位)
也通过:
4352 = 2 index lit /sup> *(1 + 2 *(2 + 16-索引位 - 块位)
求解块位我们有:
- ((4352/2 index bits -1)/2-18 +索引位)=块位,
我不知道如何直接数学地解决这个问题,鉴于变量必须是整数必须是整数,因此,只需直接求解/搜索不同的值:
如果索引位是7公式,块位是分数的,因此,
索引位为9,则块位是分数,因此不起作用。
如果 ,除:
如果索引位为8,则通过此公式,块位为2,因此:
16 =标签位 + 8 + 2,表示标记位为6,索引位为8,而块偏移为2。
由于块偏移为 2 然后,块大小为2 2 。
文本
textspan中的参数
可以省略。因此,对于您想要的东西,您只需使用children
参数,然后让第一个孩子成为一个字符。
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'L',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
const TextSpan(text: 'ike this?')
],
),
),
pdfmake仍然尚未开发垂直的功能。 strong>
但是,如果您的页面内容的高度(徽标,文本和表格)不会改变,我建议使用这样的保证金属性:
___________________
| |
| [Office Copy] |
| [Text] [Logo] |
| [ table ] | // has margin bottom to lower line
| |
| [your line here] | // has margin bottom to lower other copy
| |
| [Other Copy] |
| [Text] [Logo] |
| [ table ] |
|___________________|
使用 canvas elem ,并添加底部余量,并添加底部余量
// in table elem for example
{table: {body: [YOUR CONTENT], margin: [0, 0, 0, 20]}}
:
如果我正确理解您的问题,我认为您不需要案例声明。
SELECT age, genre, count(rating) total_rating
from User u
inner join Data d on u.userId = d.userId
inner join Item i on i.itemId = d.itemId
WHERE age >= 40
Group by age, genre;
我也尝试使用案例语句,但这有点丑陋。
SELECT age,
genre,
sum (CASE WHEN age>=40
then 1
ELSE 0
end) as 'UNDER40'
from User u
inner join Data d on u.userId = d.userId
inner join Item i on i.itemId = d.itemId
where age >=40
Group by age, genre
您要做的就是使用torch.arange()
初始化一个具有所有可能索引的多维数组。之后,使用布尔面膜从每个张量中不想要的索引索引。
import torch
a = torch.Tensor([0, 1, 2, 1, 2, 0])
n = 3
b = [torch.arange(n) for i in range(len(a))]
c = [b[i]!=a[i] for i in range(len(b))]
# use the boolean array as a mask to apply on b
d = [[b[i][c[i]] for i in range(len(b))]]
print(d) # this can be converted to a list of numbers or torch tensor
这将打印输出 - [[张量([1,2]),张量([0,2]),张量([0,1]),张量([0,2]),张量([0) ,1]),张量([1,2])]]
,您可以轻松地转换为int/numpy/torch阵列/张量。
这也可以扩展到多个维度。
您不应该尝试直接指定Incluber和Library目录,而是将root Directory(有时称为安装前缀)作为查找呼叫的提示。
您当前执行-dboost_includedir =/opt/opt/boost/lib/code>,但是
/opt/opt/boost/lib
实际上不包含任何标头文件,而是图书馆目录。虽然可以同时指定库并明确指定目录,但是这样做很易于且容易出错,因此不建议使用。
相反,您应该为库提供 root目录。安装库时,您最终将获得类似的目录结构:
/opt
+ boost
+ include
+ <all header files in here>
+ lib
+ <all library (.a and .so) files in here>
根目录是包含Incluble和Library Directories的目录,因此在这种情况下,它将是/opt/opt/boost
。
在Cmake版本3.12及更高版本中,find_package
考虑 &lt; packageName&gt; _ root
cmake variable 和&lt; packageName&gt; _root
root 系统环境环境变量作为搜索shints。此外, boost toin> boost fin boost_root
和boostroot
cmake变量是搜索提示,因为几乎永远。
因此,您的命令行确实应该像这样:
cmake -DBOOST_ROOT=/opt/boost -DCMAKE_BUILD_TYPE=Debug .. -G "Unix Makefiles"
如果仍然不起作用,这很可能意味着您正在处理非标准目录布局。咨询 findboost
的文档为了弄清楚如何在这种情况下传递其他提示,但实际上,我强烈建议您改用目录布局。
您似乎在这里进行映射操作。在这种情况下,您可以使用
MAP
并返回asyncmapsequece
:如果您可以进行
Blurrimage
async
,则可以更短:You seem to be doing an mapping operation here. In that case, you can use
map
and return anAsyncMapSequence
:If you can make
blurrImage
async
, then this can be even shorter:如何实现返回异步序列的函数,其结果依赖于另一个异步序列