Scraping URLs and Descriptions from HTML code

I’m quite new to coding and i’m struggling with returning multiple URLs and Descriptions from a block of HTML code. I know i have to loop it somehow but don’t know how. Hope someone can help me please. What i have is

function pageFunction(context) {

const $ = context.jQuery;
const venueName = $('div.collist a').first().text() + ' /';
const venueURL = $('div.collist a[href]').attr('href');


return {
    venueName,
    venueURL
};

The HTML code i’m trying to scrape is

</div>
<div class="collist">
<h3>Properties</h3>x
<ul class="list-unstyled">
<li>
<a href="search?query=500" rel="nofollow" title="Venue1"><span>London, UK</span></a> (<span>810</span>)
</li><li>
<a href="search?query=600" rel="nofollow" title="Venue2"><span>Pretoria, South Africa</span></a> (<span>820</span>)
</li><li>
<a href="search?query=700" rel="nofollow" title="Venue3"><span>New York, USA</span></a> (<span>830</span>)
</li><li>
<a href="search?query=800" rel="nofollow" title="Venue4"><span>Paris, France</span></a> (<span>840</span>)
</li><li>
<a href="search?query=900" rel="nofollow" title="Venue5"><span>Denver, USA</span></a> (<span>850</span>)
</li><li>
<a href="search?query=1000" rel="nofollow" title="Venue6"><span>Deli, India</span></a> (<span>860</span>)
</li><li>
<a href="search?query=1100" rel="nofollow" title="Venue7"><span>Lisbon, Protugal</span></a> (<span>870</span>)
</li><li>
<a href="search?query=1200" rel="nofollow" title="Venue8"><span>Madrid, Spain/span></a> (<span>880</span>)
</li><li>
<a href="search?query=1300" rel="nofollow" title="Venue9><span>Berlin, Germany</span></a> (<span>890</span>)
</li><li>
<a href="search?query=1400" rel="nofollow" title="Venue10"><span>Stockholm, Sweden</span></a> (<span>900</span>)
</li>
</ul>

My current results are

[{
  "venueName": "London, UK /",
  "venueURL": "search?query=500"
}]

But what i would like to see

[{
  "venueName": "London, UK /","venueURL": "search?query=500"
  "venueName": "London, UK /","venueURL": "search?query=600"
  "venueName": "Pretoria, South Africa /","venueURL": "search?query=700"
  "venueName": "New York, USA /","venueURL": "search?query=800"
  "venueName": "Paris, France /","venueURL": "search?query=900"
}]

Arrow Function in filter() method

I filter out every person who falls between the ages of 13 and 19.it works with a normal callback function but not the arrow function it gives an empty array.

Correct me if anything wrong in this code.

// How to access the context object with this


let peoples = [
    {name: "Mohan",age: 65},
    {name: "Raj",age: 15},
    {name: "Sam",age: 13},
    {name: "Tamil",age: 3},
    {name: "selva",age: 25},
    {name: "siva",age: 16},
    {name: "Ram",age: 18},
]

let range = {
    lower: 13,
    upper : 16
}

/* let teenagers = peoples.filter(function(people){
    return ( people.age >= this.lower && people.age <= this.upper);
},range);
console.log(teenagers); */


let teenagers = peoples.filter((people) =>{
    return (
        people.age >= this.lower && 
        people.age <= this.upper
        );
},range);

console.log(teenagers);

How can i reduce to a more concise form my JS array

There is the following piece of code that I would like to reduce to a more concise form. I think I did not make the best decision at all.
Simultaneously getting rid of the bug, which consists in limiting the operation of the program from arrays prescribed in advance in the code. Please tell me how it can be done. Jquery library 3.5.1

function onSuccess(data){
    for (k = 0; k < data.d.results.length; k++) {
        var UrlFull = data.d.results[k].ServerRelativeUrl.split('/');
        UrlFull.splice(0,4);
        var idKey = [];
        var idKey = FaendKey(UrlFull);
        if (idKey.length == 1) {
            fileSystem[idKey[0]].items.push(
                {
                    name: data.d.results[k].Name,
                    isDirectory: true, __KEY__: data.d.results[k].UniqueId,
                    dateModified: data.d.results[k].TimeLastModified,
                    items: [],
                }
            )
        } else {
            if (idKey.length == 2) {
                fileSystem[idKey[0]].items[idKey[1]].items.push(
                    {
                        name: data.d.results[k].Name,
                        isDirectory: true, __KEY__: data.d.results[k].UniqueId,
                        dateModified: data.d.results[k].TimeLastModified,
                        items: [],
                    }
                )
            }
            if (idKey.length == 3) {
                fileSystem[idKey[0]].items[idKey[1]].items[idKey[2]].items.push(
                    {
                        name: data.d.results[k].Name,
                        isDirectory: true, __KEY__: data.d.results[k].UniqueId,
                        dateModified: data.d.results[k].TimeLastModified,
                        items: [],
                    }
                )
            }
.. and then a similar structure up to the value idKey.length == 10...

Blocking IPs – any way to bypass?

I have a website based on wordpress. Unfortunately, one of the websites is blocking IPs that start at 4.523. My question is as follows:
Is it possible to bypass it in any way with a standard server (not VPS)?
For example, using cloudflare, some additional scripts, changing the configuration in wordpress, using some proxy etc.
What’s the best way to check my real outgoing ip ???

FireFox: scrollbars overlap when Windows option ‘Always show scrollbars’ is off

In an application I get a right hand side sidebar with a vertical scrollbar.
As the result if the user has moved the sidebar to the right-most part of the screen, there is 2 vertical sidebars side by side: the one of sidebar + the one of the browser.

I get an issue with FireFox(101.0.1)/Win11(21H2) when the Windows option ‘Always show scrollbars’ is off.
As FireFox is ‘hiding’ scrollbars, the locations where the scrollbars appear overlap. As the result it is not possible to mouse over and display the sidebar’s scrollbar.
It is possible to replicate the issue with the code snippet below.

By writing a few lines of javascript I can hide the browser’s scrollbar when the cursor is coming from the sidebar.
However I didn’t find any way to detect if I have to make the fix active.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div style="width:200vw; height:200vh; background-color:lightblue;"></div>
    <div style="position:fixed; width:50vw; height:50vh; bottom:0px; right:0px; overflow:auto;">
        <div style="width:200vw; height:200vh; background-color:lightgreen;"></div>
    </div>
</body>
</html>

Define a TypeScript function that will accept an argument that is a function that could have multiple signatures?

Looking for a way to define a function in TypeScript that will accept, as one of it’s arguments, a function that may be of different signatures

const foo = (a: string, b: number) => {
  //do something
}

const bar = (a: number, b: string, c: boolean) => {
  //do something
}

const myDynamicFunction = (
  str: string,
  method: ((a: string, b: number) => void) | ((a: number, b: string, c: boolean) => void), // I tried this, but no dice
  num: number,
  bool?: boolean
) => {
  if (bool) {
    method(num, str, bool)
  } else {
    method(str, num)
  }
}

myDynamicFunction(
  'string', foo, 5
)

myDynamicFunction(
  'string', bar, 5, true
)

I tried going down the “function overloads” rabbit hole, but that just left me where I started w/ essentially the same error of unexpected number of arguments.

How to access parent text which has no tag through xPath

Please find the code below

<div class="xsmall-12 medium-6 columns">
                        <label class="device-attribute-label" rel="tooltip" title="Proprietary/trade name of the medical device as used in the labeling or catalog.">Brand Name:</label>
                        Snowden-Pencer
                        <br>
                        <label class="device-attribute-label" rel="tooltip" title="Identifies a category or design of devices that have specifications, performance, size, and composition within limits set by the company.">Version or Model:</label>
                        32-0044
                        <br>
                        <label class="device-attribute-label" href="#" rel="tooltip" title="Whether the device is currently offered for sale by the device company. A device no longer in commercial distribution may or may not still be available for purchase in the marketplace.">Commercial Distribution Status:</label>
                        In Commercial Distribution
                        <br>
                        <label class="device-attribute">Catalog Number:</label>
                        32-0044
                        <br>
                        <label class="device-attribute">Company Name:</label>
                        CAREFUSION 2200, INC
                    </div>

I have to retrieve parent text like “Snowden-Pencer”, “32-0044″,”CAREFUSION 2200, INC” individually

This is what I have tried

element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div[1]/div[2]/div[1]/div[2]/section[1]/div[1]/div[1]//div[1]/*"))
    )

Output is:

output = Brand Name:

Please help me out, thanks in advance

how to hide and show button in asp.net core razor page which are not have run at Server command in c#?

I have two buttons on the asp.net core razor page as shown below code:

 <div class="row div-form-control">
                <div class="col-md-12">
                    <div class="form-group actions">
                        
                        <button type="button" name="submit" id="submit" class="btn btn-primary" action="save"><i class="icon-floppy-disk position-right"></i>Submit</button>
                        <button type="button" class="btn btn-primary" action="search"><i class="icon-new-tab position-left"></i>Search</button>

                    </div>
                </div>
 </div>

now I want to hide Submit Button in C# when the User Role is not an Admin like:

string Role="NormalUser";
if(Role!="Admin"){
 submit.Visibility = Visibility.Hidden;
}

but it does not work because in submit button I don’t have Runat=”Server” I want to hide it without using Ranat=”Server” by JavaScript or Another Method Can anyone help me how to do it?
Thanks

ReactSelect change value with dom

I’ve got this ReactSelect and would like to change the displayed value with JavaScript DOM

<div class="ReactSelect"><Select id="quarter" options={optionsQuarter}/></div>

Things like

document.getElementById("quarter").value = "..."

won’t work, so i think that i have to use a onChange function but i dont know how to access that when i change the value in another method?

Undefined value after assignment in Typescript

I’m trying to subscribe to a service in angular to get my customer’s branding info through their Id.

Firstly, I load all customer data:

this.subscription = this.burstService.getBurst().subscribe(async(response) => {
  if (response) {
    if (response.length > 0) {
      var survey = response[0];
      this.storageService.set("customer", JSON.stringify(survey));
      this.sessionJson.Id = survey.Id;
      this.sessionJson.Name = survey.Name;
      this.sessionJson.Email = survey.Email;
      this.sessionJson.SubDomainName = survey.SubDomainName;
      this.sessionJson.BusinessType = survey.BusinessType;
      this.sessionJson.Address = survey.Address;
      this.sessionJson.Phone = survey.Phone;
      this.sessionJson.Status = survey.Status;
      this.sessionJson.CreatedBy = survey.CreatedBy;
      this.sessionJson.CreationDate = survey.CreationDate;
      this.sessionJson.ModifiedBy = survey.ModifiedBy;
      this.sessionJson.ModificationDate = survey.ModificationDate;
      this.customerId = survey.Id;
    }
  }
});

Then I try to subcribe to another api to get their branding data but the customer’s Id seems undefined although when I assign its values in the getBurst bethod it equals to 1.

this.burstService.getBranding(this.sessionJson.Id!).subscribe(async(response) => {
  if (response) {
    if (response.length > 0) {
      var customerBranding = response[0];
      this.storageService.set("customerBranding", JSON.stringify(customerBranding));
    }
  }
});

Error message

Here are my observables in case its necessary:

getBurst(): Observable < CustomerModel[] > {
  var url = `https://localhost:44397/api/Customer/` + splitUrl[1];
  console.log(url);

  return this.httpClient.get < CustomerModel[] > (url, this.httpOptions);
}

getBranding(id: number): Observable < BrandingModel[] > {
  var url = `https://localhost:44397/api/Branding/` + id
  return this.httpClient.get < BrandingModel[] > (url, this.httpOptions);
}

Selecting image and store this selecting info for next page (Tarot card)

I am making a website that displays multiple tarot cards. And when the user selects the cards that they want, I want to display that selected card on the next page. So I did some code for selecting the cards, but I am not sure about the next part.

HTML

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
        <link rel="stylesheet" type="text/css" href="scriptstyle.css">
        <script type="text/javascript">
            function test_checkbox() {
                var flag=false;
                var values=document.getElementsByName("lang")
                for(var i=0; i<values.length;i++) {
                    if(values[i].checked) {
                    }
                }
            }

        </script>
    </head>

    <body>
        <ul>
            <li><input type="checkbox" id="cb1" name="lang" value="1" />
              <label for="cb1"><img src="https://picsum.photos/seed/1/100" /></label>
            </li>
            <li><input type="checkbox" id="cb2" name="lang" value="2" />
              <label for="cb2"><img src="https://picsum.photos/seed/2/100" /></label>
            </li>
            <li><input type="checkbox" id="cb3" name="lang" value="3" />
              <label for="cb3"><img src="https://picsum.photos/seed/3/100" /></label>
            </li>
            <li><input type="checkbox" id="cb4" name="lang" value="4" />
              <label for="cb4"><img src="https://picsum.photos/seed/4/100" /></label>
            </li>
          </ul>
    </body>
</html>

CSS

ul {
    list-style-type: none;
  }
  
  li {
    display: inline-block;
  }
  
  input[type="checkbox"][id^="cb"] {
    display: none;
  }
  
  label {
    border: 1px solid #fff;
    padding: 10px;
    display: block;
    position: relative;
    margin: 10px;
    cursor: pointer;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  label::before {
    background-color: white;
    color: white;
    content: " ";
    display: block;
    border-radius: 50%;
    border: 1px solid grey;
    position: absolute;
    top: -5px;
    left: -5px;
    width: 25px;
    height: 25px;
    text-align: center;
    line-height: 28px;
    transition-duration: 0.4s;
    transform: scale(0);
  }
  
  label img {
    height: 100px;
    width: 100px;
    transition-duration: 0.2s;
    transform-origin: 50% 50%;
  }
  
  :checked+label {
    border-color: #ddd;
  }
  
  :checked+label::before {
    content: "✓";
    background-color: rgb(41, 148, 255);
    transform: scale(1);
  }
  
  :checked+label img {
    transform: scale(0.9);
    box-shadow: 0 0 5px #333;
    z-index: -1;
  }

I think I should add some storing information part after

if(values[i]).checked) {
~~~}

but I am not sure about this part 🙁

How to fix dependency conflict in JavaScript project template?

I am pretty new to JS, sorry if this is a dumb thing to ask. I am working with a the Airframe React template and the steps are pretty straightforward: Unzip and run npm install from the project directory. The problem is that I get the following error when I run npm install:

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^6.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^4.19.1 || ^5.3.0" from [email protected]
npm ERR! node_modules/eslint-config-airbnb
npm ERR!   dev eslint-config-airbnb@"^17.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:UsersleordAppDataLocalnpm-cacheeresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersleordAppDataLocalnpm-cache_logs2022-06-15T05_07_36_689Z-debug-0.log

I tried changing the entry "devDependencies.eslint" to "*", but now it runs with the following error:

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersleordAppDataLocalnpm-cache_logs2022-06-15T05_11_22_330Z-debug-0.log

I also tried reinstalling Node and npm. What I find weird is that I haven’t changed anything in the project and I can’t run it.

I have tried it from both Windows 11 and WSL2. My IDE is WebStorm and everything is up to date.

How can I resolve the dependency conflict?

Count similarity percentage of two images by using Tracking.js Feature Descriptor (Brief)

For those who don’t know about what is Tracking.js, The tracking.js library brings different computer vision algorithms and techniques into the browser environment. Using modern HTML5 specifications, it enables you to do real-time color tracking, face detection, and much more. Learn more about it on https://trackingjs.com/

But my problem is I want to see the percentage similarity of the two images by using Tracking.js Feature Descriptor (Brief). I read the documentation but can’t understand properly.

  window.onload = function() {
    var width = 393;
    var height = 295;
    var canvas = document.getElementById('canvas');
    var context = canvas.getContext('2d');

    var image1 = document.getElementById('image1');
    var image2 = document.getElementById('image2');

    window.descriptorLength = 256;
    window.matchesShown = 30;
    window.blurRadius = 3;

    var doMatch = function() {
      tracking.Brief.N = window.descriptorLength;

      context.drawImage(image1, 0, 0, width, height);
      context.drawImage(image2, width, 0, width, height);
  
      var imageData1 = context.getImageData(0, 0, width, height);
      var imageData2 = context.getImageData(width, 0, width, height);
  
      var gray1 = tracking.Image.grayscale(tracking.Image.blur(imageData1.data, width, height, blurRadius), width, height);
      var gray2 = tracking.Image.grayscale(tracking.Image.blur(imageData2.data, width, height, blurRadius), width, height);
  
      var corners1 = tracking.Fast.findCorners(gray1, width, height);
      var corners2 = tracking.Fast.findCorners(gray2, width, height);
  
      var descriptors1 = tracking.Brief.getDescriptors(gray1, width, corners1);
      var descriptors2 = tracking.Brief.getDescriptors(gray2, width, corners2);
  
      var matches = tracking.Brief.reciprocalMatch(corners1, descriptors1, corners2, descriptors2);

      matches.sort(function(a, b) {
        return b.confidence - a.confidence;
      });
  
      var similarityPercentage = **What Shoud I Count Here?**;
      console.log(similarityPercentage)
    };

    doMatch();

how to make margin-left atuo increment with javascript bootstrap 3.0.0

i need add margin-left into .card class “style” element auto generate margin-left every time post page input.

my jquery version 1.12.4

my idea is

if .card css style margin-left 0 and with 479px set position 0
else set position margin-left 479px 
else set position mergin-left ...px

becuse im new learning javascript, so im trying help ask question with this code

enter link description here