I would like to take the text "msg-dblcheck" within this code and insert it into an MSaccess table:
<div class="_32uRw">
<span data-icon="msg-dblcheck" class="">
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 15" width="16" height="15">
<path fill="#92A58C" d="M15.01 3.316l-.478-.372a.365.365 0 0 0-.51.063L8.666 9.879a.32.32 0 0 1-.484.033l-.358-.325a.319.319 0 0 0-.484.032l-.378.483a.418.418 0 0 0 .036.541l1.32 1.266c.143.14.361.125.484-.033l6.272-8.048a.366.366 0 0 0-.064-.512zm-4.1 0l-.478-.372a.365.365 0 0 0-.51.063L4.566 9.879a.32.32 0 0 1-.484.033L1.891 7.769a.366.366 0 0 0-.515.006l-.423.433a.364.364 0 0 0 .006.514l3.258 3.185c.143.14.361.125.484-.033l6.272-8.048a.365.365 0 0 0-.063-.51z"></path>
</svg>
</span>
</div>
this is my tried code:
spnt= bot.findElementByClassName("_32uRw").text
unfortunately I insert field "-1".
Where am I wrong? In selecting the field? Should I search with xpath? Can someone help me?
Do you mean something like:
.FindElementByCss("._32uRw span").Attribute("data-icon")
I don't know how many class names you have before this one though. The above will match on the first by that class name with a following span.
You can do FindElementsByCSS, and index into the returned webElements collection e.g. .FindElementsByCss("._32uRw span")(1).Attribute("data-icon")
With the above you don't need .Text on the end. This would return msg-dblcheck.
For the last element with this attribute:
Dim numElements As Long, lastElement As WebElement
numElements = bot.FindElementsByCss("[data-icon='msg-dblcheck']").Count
Set lastElement = bot.FindElementsByCss("[data-icon='msg-dblcheck']")(numElements-1)
To include the class name of the element before change the text [data-icon='msg-dblcheck'] to ._32uRw [data-icon='msg-dblcheck'] .
Related
I am trying to make a tiktok bot, but I am having issues entering in text to their caption section(see screenshot below). I've tried using wait till element clickable function, but for some reason I can not use selenium to detect this element, would anyone have any suggestions on how to go about this, thank you in advance :)
My current code is below:
driver.get("https://www.tiktok.com/upload?lang=en")
try:
element = WebDriverWait(driver, waittime).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#root > div > div > div > div > div.jsx-410242825.contents-v2 > div.jsx-2580397738.form-v2 > div.jsx-2580397738.caption-wrap-v2 > div > div:nth-child(1) > div.jsx-1717967343.margin-t-4 > div > div.jsx-1043401508.jsx-723559856.jsx-1657608162.jsx-3887553297.icon-style.hash')))
except:
driver.quit()
element.click()
try:
element = WebDriverWait(driver, waittime).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#root > div > div > div > div > div.jsx-410242825.contents-v2 > div.jsx-2580397738.form-v2 > div.jsx-2580397738.caption-wrap-v2 > div > div:nth-child(1) > div.jsx-1717967343.margin-t-4 > div > div.jsx-1043401508.jsx-723559856.jsx-1657608162.jsx-3887553297.editor > div > div > div > div > div > div > span > span > span')))
except:
driver.quit()
element.clear()
element.send_keys(mainCaption)
Element snapshot:
HTML <br> Tag
The <br> tag inserts a single line break. The <br> tag is an empty tag which means that it has no end tag and is useful for writing addresses or poems to enter line breaks, not to add space between paragraphs. Hence, you can't send any text within a <br> element.
Presumably, <br> tags will have parent/ancestor <p> tags. As an example:
<p>Be not afraid of greatness.<br>
Some are born great,<br>
some achieve greatness,<br>
and others have greatness thrust upon them.</p>
<p><em>-William Shakespeare</em></p>
So in these cases you need to target the parent/ancestor <p> tags to send the text.
<a href="/what-to-watch/fan-favorites/?ref_=hm_fanfav_sm" class="ipc-title ipc-title--
subsection-title ipc-title--baseAlt ipc-title--on-textPrimary ipc-title-link-wrapper"
tabindex="0"><h3 class="ipc-title__text">Fan favorites<svg width="24" height="24"
xmlns="http://www.w3.org/2000/svg" class="ipc-icon ipc-icon--chevron-right-inline ipc-
icon--inline ipc-title-link-chevron" viewBox="0 0 24 24" fill="currentColor"
role="presentation"><path d="M5.622.631A2.153 2.153 0 0 0 5 2.147c0 .568.224 1.113.622
1.515l8.249 8.34-8.25 8.34a2.16 2.16 0 0 0-.548 2.07c.196.74.768 1.317 1.499 1.515a2.104
2.104 0 0 0 2.048-.555l9.758-9.866a2.153 2.153 0 0 0 0-3.03L8.62.61C7.812-.207 6.45-.207
5.622.63z"></path></svg></h3><div class="ipc-title__description">This week's top TV and
movies</div></a>
and
<a class="ipc-poster-card__title ipc-poster-card__title--clamp-2
ipc-poster-card__title--clickable" aria-label="View title page for
Shang-Chi and the Legend of the Ten Rings" href="/title/tt9376612/?
ref_=watch_fanfav_tt_t_2"><span data-testid="title">Shang-Chi and the
Legend of the Ten Rings</span></a>
Are the HTML structures of the sites I want my spider to crawl with the code:
import scrapy
from scrapy.crawler import CrawlerProcess
class imdb_favorites(scrapy.Spider):
name = "imdB Favorites"
def start_requests(self):
url = "https://www.imdb.com"
yield scrapy.Request(url = url,
callback = self.parse_front)
def parse_front(self, response):
# Get the link of 'What to watch section'
fan_favorites = response.css('div.fan-picks>a::attr(href)')
link_to_follow = fan_favorites.extract()
for i in link_to_follow:
url2 = url + i
print(url2)
yield response.follow(url = url2,
callback = self.parse_2)
def parse_2(self, response):
# Gets the links of the movies in what to watch section.
what_to_watch = response.css('a.ipc-poster-card__title::attr(href)').extract()
for a in what_to_watch:
url3 = "https://www.imdb.com" + a
print(url3)
yield response.follow(url = url3,
callback = parse_3)
process= CrawlerProcess()
process.crawl(imdb_favorites)
process.start()
The problem is that print() functions do not work in for loops so I cannot see if my code crawls properly or not so I cannot teach myself furthermore. Thanks your interest.
Print should work in a loop; this indicates you never actually enter the loop. Print/log (see below) information about the iterable before entering the loop to see if it is in fact an iterable. Printing print(len(what_to_watch)) or print(len(link_to_follow)) right before each loop should return an integer if it is an iterable. You can then log individual aspects of the iterable such as the first element. Note: this is a makeshift way to debug, and I would recommend using scrapy shell or running the spider in debug mode and putting breakpoints in your loops to see if they ever get hit. See scrapy documentation for information about debugging.
If printing really is the problem, try logging instead of printing. it's possible you have some setting configured such that it is not handling standard-output the way you are expecting. Read more about scrapy logging here. You can bulk replace your print() with logging.info().
I want to get text (_reserve0|uint112 : 80540710293008523149) from these tags . check image.
Image
I'm getting only the first text value (_reserve0|uint112).
My code:
reserve_unit0 = driver.find_element_by_xpath("//*[#id='readCollapse8']/div/form/div/i[4]")
print(reserve_unit0.text)
I tried this code but still, I get only "_reserve0|uint112"
print(driver.execute_script('return arguments[0].lastChild.textContent;', WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "#readCollapse8 > div > form > div > i:nth-child(8)")))).strip())
The SVG was copy pasted from the source into a .vue file as a component, it works in Chrome but it throws this error in Firefox and the entire icons won't render. Since each of those are throwing the same error, I'll just pick one to represent the problem. Please have a look.
[Vue warn]: Failed to resolve async component: function IconInstagram() {
return __webpack_require__.e(/*! import() | components/icon-instagram */ "components/icon-instagram").then(__webpack_require__.bind(null, /*! ../../components/Icon/Instagram.vue */ "./components/Icon/Instagram.vue")).then(function (c) {
return Object(_utils__WEBPACK_IMPORTED_MODULE_8__["wrapFunctional"])(c.default || c);
});
}
Reason: ChunkLoadError: Loading chunk components/icon-instagram failed.
(error: http://localhost:3000/_nuxt/components/icon-instagram.js)
<template>
<!-- IconInstagram.vue -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g fill="currentColor">
<path
d="M20.947 8.305a6.53 6.53 0 0 0-.419-2.216 4.61 4.61 0 0 0-2.633-2.633 6.606 6.606 0 0 0-2.186-.42c-.962-.043-1.267-.055-3.709-.055s-2.755 0-3.71.055a6.606 6.606 0 0 0-2.185.42 4.607 4.607 0 0 0-2.633 2.633 6.554 6.554 0 0 0-.419 2.185c-.043.963-.056 1.268-.056 3.71s0 2.754.056 3.71c.015.748.156 1.486.419 2.187a4.61 4.61 0 0 0 2.634 2.632 6.584 6.584 0 0 0 2.185.45c.963.043 1.268.056 3.71.056s2.755 0 3.71-.056a6.59 6.59 0 0 0 2.186-.419 4.615 4.615 0 0 0 2.633-2.633c.263-.7.404-1.438.419-2.187.043-.962.056-1.267.056-3.71-.002-2.442-.002-2.752-.058-3.709zm-8.953 8.297c-2.554 0-4.623-2.069-4.623-4.623s2.069-4.623 4.623-4.623a4.623 4.623 0 0 1 0 9.246zm4.807-8.339c-.597 0-1.078-.482-1.078-1.078a1.077 1.077 0 1 1 2.155 0c0 .596-.482 1.078-1.077 1.078z"
></path>
<circle cx="11.994" cy="11.979" r="3.003"></circle>
</g>
</svg>
</template>
Both browser and Nuxt.js installed are on latest stable channel. What should I do to fix this?
It turned out to be an ad-blocker trying to block access to the scripts. Disabling it fixes the error and it doesn't appear anymore.
This question solves the problem. Please have a look in there for the detailed explanation.
This question already has answers here:
What's the difference between & and && in JavaScript?
(4 answers)
Closed 4 years ago.
What's the difference between the & and && in Vue.js?
I test the:
<span
v-if="1 > 0 & 2 > 1"
>
span
</span>
and
<span
v-if="1 > 0 && 2 > 1"
>
span
</span>
both the text span will show.
So is there some difference between them in Vue.js?
They have the same type of logic. 0101 & 1010 = 0000. However && will not valuate the second one if the first on is false, it will always consider the second one true..
try this
<span
v-if="1 > 3 && 2 > 3"
>
span
</span>