Scraping LinkedIn company name, location and followers from HTML script - selenium

I'm able to scrape the company's name, location. Using the code below. But I'm facing difficulty to scrape the number of followers
Here is the HTML script for reference.
<div class="block mt2">
<div>
<h1 class="ember-view t-24 t-black t-bold full-width" id="ember28" title="Pacific Retail Capital Partners">
<span dir="ltr">Pacific Retail Capital Partners</span>
</h1>
<p class="org-top-card-summary__tagline t-16 t-black">
Our decades of experience and innovative strategies are transforming retail-led centers into high-performing properties.
</p>
<!-- -->
<div class="org-top-card-summary-info-list t-14 t-black--light">
<div class="org-top-card-summary-info-list__info-item">
Leasing Non-residential Real Estate
</div>
<!-- -->
<div class="inline-block">
<div class="org-top-card-summary-info-list__info-item">
El Segundo, CA
</div>
<!-- -->
<div class="org-top-card-summary-info-list__info-item">
4,047 followers
</div>
</div>
</div>
</div>
</div>
Scrapping company's name was easy and direct
info_div = soup.find('div', {'class' : 'block mt2'})
#print(info_div)
info_name = info_div.find_all('h1')
company_name = info_name[0].get_text().strip()
print(company_name, type(company_name),len(company_name))
Company location was accessed using this.
info_block = info_div.find_all('div', {'class' : 'inline-block'})
info_loc = info_block[0].find('div', {'class' : 'org-top-card-summary-info-list__info-item'}).get_text().strip()
print(info_loc)
How can I scrape/access second element i.e. 4047 followers ?

You can use the contains operator within the CSS selector, in this case we're searching for followers in a div with the specified class name:
followers_div = soup.select_one('.org-top-card-summary-info-list__info-item:contains(followers)')
This returns:
<div class="org-top-card-summary-info-list__info-item">
4,047 followers
</div>

Related

How to extract item array from html

I am using scrapy to extract an item list into an array with the following info:
<div class="row">
<div class="col-md-4">
<p class="title">title info</p>
<p class="content">txt info</p>
</div>
<div class="col-md-4">
<p class="title">title info</p>
<p class="content">txt info</p>
</div>
</div>
Somehow my syntax seem to be wrong:
>>> response.xpath('//div[#class="row"]/div[#class="col-md-4"]/p/text()').extract()
[]
There might be another row class ahead of this item
You want to scrape https://www.watchmaster.com/de/bvlgari/automatic/bb38sl-auto/UELG3X5E7R page.
For example to collect Details from page it is better to add extra parent selector like here: response.css("div#watch-details-tab div.row div ::text").extract() to avoid collecting data from alike structures.
If you need to collect it by feature, try:
for row in response.css('div#watch-details-tab div.row div'):
k = row.css('p.title::text').get()
v = row.css('p.content::text').get()
# and then your logic for this data

Angular 5 - Bindings cannot contain assignments

<li class="tabRow tabRowLeft" *ngFor="let gene of filteredgene = (seq.genes) | limitTo:filteredgene.length/2+filteredgene.length%2">
<div class="displayFlex" (click)="showGeneRecord(gene.geneName,'ATTRIBUTE','.addPopup.attributeRisk')">
<div class="tabCell">
<div class="cellItem displayFlex">
<h4 class="flex1">{{gene.geneName}}</h4>
</div>
</div>
<div class="tabCell">
<div class="cellItem displayFlex">
<h4 class="flex1">{{gene.geneScore}}</h4>
</div>
</div>
</div>
</li>
I am trying to get the value in filteredgene and then for loop on filteredgene . I am getting error Bindings cannot contain assignments. Any one knows, what should I do resolve and get this thing done.
For limit to I have created a pipe too.

bootstrap notifications on homepage

I want to show notifications of data inserted on the homepage of dashboard.
Dashboard has three pages of data insertion. I want to display information of data insertion on homepage.
<div class="content">
<div class="alert alert-info">
<span id = "t1">
<b> Task1 - </b> This is a regular notification made with ".alert-info"</span>
</div>
<div class="alert alert-success">
<span id = "t2">
<b> Task 2 - </b> This is a regular notification made with ".alert-success"</span>
</div>
<div class="alert alert-danger">
<span id = "t3">
<b> task 3 - </b> This is a regular notification made with ".alert-danger"</span>
</div>
</div>
Look at Materialize Toasts to popup an information box when a data is successfully added.
I think bootstrap only provides a css information box

Schema Tag: The property priceSpecification is not recognized by Google

priceSpecification schema is returning error, how to resolve it? Website has classified listings for used cars posted by users.
Here are schema tags (screenshots attached), unable to paste schema tags code.
<div class="pos-rel" itemprop="itemOffered" itemscope itemtype="http://schema.org/Car" >
<h3 itemprop="name">Toyota Vitz F 1.0 for Sale</h3>
<div class="price-details generic-dark-grey mb5 mt10" itemprop="priceSpecification" itemscope itemtype="http://schema.org/UnitPriceSpecification">
<meta itemprop="priceCurrency" content="PKR">
<meta itemprop="price" content="1585000">
<span class='pkr'>PKR</span> 15.9 <span>lacs</span>
</div>
Read the docs, http://schema.org/Car. Go to bottom of page, click on microdata tag of example. Notice http://schema.org/Offer is part of the person schema. You could do it in two sections like their example or use something like this
<!-- Car Details -->
<div id="product" itemprop="itemOffered" itemscope itemtype="http://schema.org/Car">
<h3 itemprop="name">Toyota Vitz F 1.0 for Sale</h3>
<!-- Seller Details -->
<div itemscope itemtype="http://schema.org/Person">
<strong>Contact Name: </strong> <span itemprop="name givenName">Brent</span>
<div itemprop="makesOffer" itemscope itemtype="http://schema.org/Offer" itemref="product">
<span itemprop="priceCurrency" content="PKR">PKR</span>
<span itemprop="price" content="1585000">15.9</span>
</div>
</div>
</div>
Notice code will validate here: https://search.google.com/structured-data/testing-tool

How to use webdriver to randomly click on a button with precondication

I'm trying to write a test script with flight booking tickets scenario like this: Randomly click a button which description contains keyword "tax not included",then results shows; Randomly click a button which not contains keyword, then price shows.
For instance: Go to ebay.com and search "iPhone",in the search result page,randomly click a url which label contains keyword "Buy It Now"...
Anybody got a clean solution to that? Thanks in advance.
I have no clue to handle this case...
here is my code:
public void flightSchedule(){
if (be.isTextPresent(locator.getValue("tax_text"), 1000)){ //if keywords displays
ArrayList<WebElement> lists = (ArrayList<WebElement>) be.getBrowserCore().findElements(contains(text(),'tax not included'));
Random random = new Random();
int ra = random.nextInt(lists.size());
WebElement element = (WebElement) lists.get(ra);
}
the page source code is:
<div id="itemBarXI151" class="avt_column avt_column_trans">
<div class="b_avt_lst">
<div class="avt_trans">
<div class="avt_column_1st">
<div class="avt_column_sp">
<p>
<span class="highlight">new york city</span>
(tax not included)
</p>
</div>
<div class="avt_column_2nd">
</div>
<div class="c6">
<div class="c7"> </div>
<div class="c8">
<div class="a_booking">
<a id="openwrapperbtnXI147" class="btn_book" title="booking tickets" onfocus="this.blur();" hidefocus="on" href="##" data-evtdataid="XI147">
<span>
<b>booking</b>
</span>
</a>
</div>
</div>
my xpath is:"//div[#class='avt_column avt_column_trans'] [contains(text(),'booking')]",but it doesn't work.