Why this css selector is not working properly? - css-selectors

While Extracting 1st Company's name using css selectors output is perfect But Second selector "sel2" returns None
from requests_html import HTMLSession
session = HTMLSession()
page=session.get("https://www.moneycontrol.com/stocks/marketstats/indcomp.php")
#print(page)
sel1 = '#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm.PR.Ohidden > table > tbody > tr:nth-child(1) > td.PR > span.gld13.disin'
sel2 = '#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm.PR.Ohidden > table > tbody > tr:nth-child(2) > td.PR > span.gld13.disin'
temp=page.html.find(sel1, first=True).text
print(temp.strip("\n Add to \n Watchlist | Portfolio"))
temp=page.html.find(sel2, first=True).text
print(temp.strip("\n Add to \n Watchlist | Portfolio"))
Output Needed
Carborundum
Grindwell Norto
For More refernece and choosing selectors:-
https://www.moneycontrol.com/stocks/marketstats/indcomp.php

In the case of this particular page, you can use much simpler selectors:
sel1 = 'span > a'
temp=page.html.find(sel1)
print(temp[0].text)
print(temp[1].text)
Output:
Carborundum
Grindwell Norto

Related

Drilldown method always return null with Cube JS

I have a problem with cubejs library. when i call the method drilldown from a measure.
i was puting the drill members field on my schema but always return null.
this is my measure from the schema
compromisoFinalMuyAlta: {
sql: `
CASE
WHEN (
(sum(
CASE
WHEN (${CUBE}.id_tipo_cobertura = 4 AND ${CUBE}.id_bi_rango_sla = 5) THEN ${CUBE}.total_cuentas_rango
END
) - ${inactivasTotalMuyAlta}) > 0
) THEN ROUND(SUM(
CASE
WHEN (${CUBE}.id_tipo_cobertura = 4 AND ${CUBE}.id_bi_rango_sla = 5) THEN ${CUBE}.total_cuentas_rango
END
)) - ${inactivasTotalMuyAlta}
ELSE 0
END
`,
type: `number`,
title: 'Resultado final',
drillMembers:[`${CUBE}.id_tipo_cobertura`,`${CUBE}.total_cuentas_rango`]
}
this the method what i have the resultset and try to call the drilldown method
public BuscarDetalle(columnValue) {
console.log(this.resultQuery);
const queryDetail = this.resultQuery.drillDown({
xValues: ["0 - 3 días"],
yValues: ["compromiso_real.id_cliente", "SlaCompromisos.compromisoFinalMuyAlta"]
});
console.log(queryDetail);
}
and this is the table from cube.
enter image description here
First of all, Thanks.

How to only index collection items that match specific condition?

In my project I want to index the data.
The code of views:
- #phones.each.with_index(1) do |(phone,no_of_duplicate),index|
.row.py-2
.col-2 = index
- if no_of_duplicate.count > 1
.col-3 = phone
.col-3 = no_of_duplicate.count
.col-4 .......................................
I obtain the result as
If I change the code on views as:
- #phones.each.with_index(1) do |(phone,no_of_duplicate),index|
- if no_of_duplicate.count > 1
.row.py-2
.col-2 = index
.col-3 = phone
.col-3 = no_of_duplicate.count
The got the result as:
How can I solve this?
You can filter before assigning indexes and rendering:
#phones.filter { |(_,no_of_duplicate)| no_of_duplicate.count > 1 }.each <...>

Solr + Typo3 : Hide facets based on indexConfig

Is it possible to hide a facet based on the current table ?
Exemple, I have a "news" table and a table "project".
But if I do this :
facets.state {
label.data = LLL:EXT:skin/Resources/Private/Language/locallang.xlf:search.rfp_state
field = state_intS
renderingInstruction = TEXT
renderingInstruction {
field = optionValue
wrap = {LLL:EXT:projects/Resources/Private/Language/locallang_db.xlf:tx_projects_domain_model_requestforprojects.state.items.|}
insertData = 1
}
includeInAvailableFacets = 0
}
The includeInAvailableFacets is
for both my news and project
Looked into the docs, but couldn't find what i've been looking for...
https://docs.typo3.org/p/apache-solr-for-typo3/solr/master/en-us/Configuration/Reference/TxSolrSearch.html#faceting-facets-facetname-includeinavailablefacets
Got it !
You have to declare condition to your precise page like this :
Where 1772 is your page id. Found a lead here : https://docs.typo3.org/m/typo3/reference-typoscript/8.7/en-us/Conditions/Reference/
[globalVar = TSFE:id =1772] && [globalVar = TSFE:id = {$plugin.tx_anrskin.settings.pages.solrSortDateDesc}] && [globalVar = GP:q =]
plugin.tx_solr.search.query.sortBy = sortDate_dateS desc
plugin.tx_solr.search.sorting = 0
plugin.tx_solr.search.query.returnFields = *, score
plugin.tx_solr.search.faceting.facets.dateinterval.includeInAvailableFacets = 0
plugin.tx_solr.search.faceting.facets.item.includeInAvailableFacets = 0
plugin.tx_solr.search.faceting.facets.name.includeInAvailableFacets = 0
[globalVar]

TYPO3 javascript footer with typoscript, WHERE clause breaks SELECT functionality

I have a curious page structure, colPos = 0 of the subpages is used as content for its parent ... these pages have animations that need code in the parent page footer so I added the field tx_add_animation_code in table tt_content and this code needs to be collected.
setup.txt:
# footer script
page.footerData {
# collect subpages
5 = LOAD_REGISTER
5 {
pageIds.cObject = CONTENT
pageIds.cObject {
table = pages
select {
pidInList = this
recursive = 0
selectFields = uid
where = {#no_search}=0
}
renderObj = TEXT
renderObj {
field = uid
required = 1
wrap = |,
}
}
}
# open javascript
10 = TEXT
10.value (
<script type="text/javascript">
)
# test id collection
25 = TEXT
25 {
data = register:pageIds
noTrimWrap (
|
/* subpage Ids: | */
|
)
}
# collect animation code from CE's on subpages
20 = CONTENT
20 {
table = tt_content
select {
pidInList.data = register:pageIds
# THIS LINE BREAKS FUNCTIONALITY
where = {#colPos}=0
}
renderObj = COA
renderObj {
10 = TEXT
10.stdWrap.field = tx_add_animation_code
}
if {
value = pagets__homepage,pagets__onepage
isInList.data = TSFE:page|backend_layout
}
}
# close javascript
30 = TEXT
30.value (
</script>
)
90 = RESTORE_REGISTER
}
where = {#colPos}=0 breaks the functionality, and if I do not include it, of course, the field is collected from all the content elements ...
what is the issue ?
Please make sure that there are really some Content Elements on the Subpages having colPos=0. Please note that some extensions like gridelements or other multicol extensions will set the colPos of their childelements to something negative like -67 so they won't match the select-statement anymore.

Error in reactjs +materail-ui

I am getting this error while building a simple app which has two routes one to '/' and other to '/search'. I have used various components of material-ui.
The problem is when I route to '/search' the following error is thrown:
I have tried all necessary things but unable to figure out what's wrong?
I am just posting half of code here:
function capitalizeFirstLetter(string) {
28 | process.env.NODE_ENV !== "production" ? (0, _warning2.default)(typeof string === 'string', 'Material-UI: capitalizeFirstLetter(string) expects a string argument.') : void 0;
29 |
> 30 | return string.charAt(0).toUpperCase() + string.slice(1);
31 | } // weak
32 |
33 | function contains(obj, pred) {
View compiled
Typography
node_modules/material-ui/Typography/Typography.js:114
111 | other = (0, _objectWithoutProperties3.default)(props, ['align', 'classes', 'className', 'component', 'color', 'gutterBottom', 'headlineMapping', 'noWrap', 'paragraph', 'type']);
112 |
113 |
> 114 | var className = (0, _classnames2.default)(classes.root, classes[type], (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes['color' + (0, _helpers.capitalizeFirstLetter)(color)], color !== 'default'), (0, _defineProperty3.default)(_classNames, classes.noWrap, noWrap), (0, _defineProperty3.default)(_classNames, classes.gutterBottom, gutterBottom), (0, _defineProperty3.default)(_classNames, classes.paragraph, paragraph), (0, _defineProperty3.default)(_classNames, classes['align' + (0, _helpers.capitalizeFirstLetter)(align)], align !== 'inherit'), _classNames), classNameProp);
115 |
116 | var Component = componentProp || (paragraph ? 'p' : headlineMapping[type]) || 'span';
117 |
View compiled
mountIndeterminateComponent
node_modules/react-dom/cjs/react-dom.development.js:8032
8029 | warning(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
8030 | }
8031 | ReactCurrentOwner.current = workInProgress;
> 8032 | value = fn(props, context);
8033 | }
8034 | // React DevTools reads this flag.
8035 | workInProgress.effectTag |= PerformedWork;
View compiled
beginWork
node_modules/react-dom/cjs/react-dom.development.js:8221
8218 |
8219 | switch (workInProgress.tag) {
8220 | case IndeterminateComponent:
> 8221 | return mountIndeterminateComponent(current, workInProgress, renderExpirationTime);
8222 | case FunctionalComponent:
8223 | return updateFunctionalComponent(current, workInProgress);
I see in Typography.js that it use capitalizeFirstLetter for color and align.
Check if you inserted there something that is not a string.

Resources