kandi background
Explore Kits

otter | 阿里巴巴分布式数据库同步系统

 by   alibaba Java Version: otter-4.2.18 License: Apache-2.0

 by   alibaba Java Version: otter-4.2.18 License: Apache-2.0

Download this library from

kandi X-RAY | otter Summary

otter is a Java library. otter has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
阿里巴巴分布式数据库同步系统(解决中美异地机房)
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • otter has a medium active ecosystem.
  • It has 7079 star(s) with 2420 fork(s). There are 581 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 285 open issues and 706 have been closed. On average issues are closed in 121 days. There are 12 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of otter is otter-4.2.18
otter Support
Best in #Java
Average in #Java
otter Support
Best in #Java
Average in #Java

quality kandi Quality

  • otter has 0 bugs and 0 code smells.
otter Quality
Best in #Java
Average in #Java
otter Quality
Best in #Java
Average in #Java

securitySecurity

  • otter has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • otter code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
otter Security
Best in #Java
Average in #Java
otter Security
Best in #Java
Average in #Java

license License

  • otter is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
otter License
Best in #Java
Average in #Java
otter License
Best in #Java
Average in #Java

buildReuse

  • otter releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • otter saves you 62343 person hours of effort in developing the same functionality from scratch.
  • It has 70817 lines of code, 6459 functions and 1026 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
otter Reuse
Best in #Java
Average in #Java
otter Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed otter and discovered the below as its top functions. This is intended to give you an instant insight into otter implemented functionality, and help decide if they suit your requirements.

  • Interns the event data
  • Process selector .
  • Get list of all processes
  • parse node task
  • save db batch
  • Acquire lock .
  • On file conflict detection .
  • Do save .
  • Do second phase .
  • Collect connection statistics .

otter Key Features

阿里巴巴分布式数据库同步系统(解决中美异地机房)

HTML Agility Pack foreach loop not iterating for data grid (C#)

copy iconCopydownload iconDownload
HtmlWeb web = new HtmlWeb();

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc = web.Load("https://klinikaikozpont.unideb.hu/doctor_finder");

const string doctorListItem = "div[contains(@class, 'doctor-list-item-model')]";
const string cardContent = "div[contains(@class, 'card-content')]";
var doctorCards = doc.DocumentNode.SelectNodes($"//{doctorListItem}/{cardContent}");

var doctors = new List<Doctor>();
foreach (var card in doctorCards)
{
    var name = card.SelectSingleNode("./h3")?.InnerText;
    const string departmentNode = "div[contains(@class, 'department-name')]";
    var department = card.SelectSingleNode($"./{departmentNode}/p")?.InnerText;
    // other proprties...

    doctors.Add(new Doctor{NameAndTitle = name, Department = department});
}

// I took the liberty to make this class easier to understand
public class Doctor
{
    public string NameAndTitle { get; set; }
    public string Department { get; set; }
    // Add other properties
}

Why isn't there space between my menu items?

copy iconCopydownload iconDownload
<li><a href='#'>Home</a></li>
-----------------------
<nav class='container'>
   <div class='logo'><i class="fa-solid fa-otter"></i>Sea otters</div>  
      <ul>
         <li><a href='#'>Home</a></li>
         <li><a href='#'>Species</a></li>
         <li><a href='#'>Habitat</a></li>
         <li><a href='#'>Behavior</a></li>
         <li><a href='#' class='highlight'>Ecology</a></li>
     </ul>
</nav>

how do I use &quot;this&quot; on an component function in react?

copy iconCopydownload iconDownload
  constructor(props) {
    super(props);
    this.state = {
      fact: ""
    };

    // Here you will bind the functions so they can be callable with this
    this.getFact = this.getFact.bind(this);
    this.Animal = this.Animal.bind(this);
  }
function Animal(props) {
  return (
    <div>
      <h1>{props.name}</h1>
      <button onClick={() => props.getFact(props.endpoint)}>
        get a {props.name.toLowerCase()} fact
      </button>
    </div>
  );
}

class AppReactWay extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      fact: ""
    };
    this.getFact = this.getFact.bind(this);
  }

// Same code as you have

  render() {
    return (
      <div className="App">
        <div>
          <p>{this.state.fact}</p>
        </div>
        <div className="animals">
          <Animal
            name="Dog"
            getFact={this.getFact}
            endpoint="https://some-random-api.ml/facts/dog"
          />
        </div>
      </div>
    );
  }
}

export default App;
  getFact(endpoint) {
    fetch(endpoint)
      .then((response) => response.json())
      .then(({ fact }) => {
        this.setState({
          fact
        });
      });
  }
-----------------------
  constructor(props) {
    super(props);
    this.state = {
      fact: ""
    };

    // Here you will bind the functions so they can be callable with this
    this.getFact = this.getFact.bind(this);
    this.Animal = this.Animal.bind(this);
  }
function Animal(props) {
  return (
    <div>
      <h1>{props.name}</h1>
      <button onClick={() => props.getFact(props.endpoint)}>
        get a {props.name.toLowerCase()} fact
      </button>
    </div>
  );
}

class AppReactWay extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      fact: ""
    };
    this.getFact = this.getFact.bind(this);
  }

// Same code as you have

  render() {
    return (
      <div className="App">
        <div>
          <p>{this.state.fact}</p>
        </div>
        <div className="animals">
          <Animal
            name="Dog"
            getFact={this.getFact}
            endpoint="https://some-random-api.ml/facts/dog"
          />
        </div>
      </div>
    );
  }
}

export default App;
  getFact(endpoint) {
    fetch(endpoint)
      .then((response) => response.json())
      .then(({ fact }) => {
        this.setState({
          fact
        });
      });
  }
-----------------------
  constructor(props) {
    super(props);
    this.state = {
      fact: ""
    };

    // Here you will bind the functions so they can be callable with this
    this.getFact = this.getFact.bind(this);
    this.Animal = this.Animal.bind(this);
  }
function Animal(props) {
  return (
    <div>
      <h1>{props.name}</h1>
      <button onClick={() => props.getFact(props.endpoint)}>
        get a {props.name.toLowerCase()} fact
      </button>
    </div>
  );
}

class AppReactWay extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      fact: ""
    };
    this.getFact = this.getFact.bind(this);
  }

// Same code as you have

  render() {
    return (
      <div className="App">
        <div>
          <p>{this.state.fact}</p>
        </div>
        <div className="animals">
          <Animal
            name="Dog"
            getFact={this.getFact}
            endpoint="https://some-random-api.ml/facts/dog"
          />
        </div>
      </div>
    );
  }
}

export default App;
  getFact(endpoint) {
    fetch(endpoint)
      .then((response) => response.json())
      .then(({ fact }) => {
        this.setState({
          fact
        });
      });
  }

Can I see all attributes of a pyplot without showing the graph?

copy iconCopydownload iconDownload
import matplotlib.pyplot as plt
import numpy as np


def is_horizontal(line2d):
    x, y = line2d.get_data()
    y = np.array(y)  # The axhline method does not return data as a numpy array
    y_bool = y == y[0]  # Returns a boolean array of True or False if the first number equals all the other numbers
    return np.all(y_bool)


t = np.linspace(-10, 10, 1000)

plt.plot(t, t**2)
plt.plot(t, t)
plt.axhline(y=5, xmin=-10, xmax=10)

ax = plt.gca()

assert any(map(is_horizontal, ax.lines)), 'There are no horizontal lines on the plot.'

plt.show()

How do I check against the first 7 elements of the list in order to print some text?

copy iconCopydownload iconDownload
# Create a list of hangman words
  wordList = ["cat","dog","mouse", "giraffe", "otter", "shark", "sheep", "car", "motorbike",
  "bus", "aeroplane", "pizza", "chips", "cheese"]

# Choose a word from the list at random
  wordChosen = random.choice(wordList)

# Keep asking the player until all letters are guessed
  while display != wordChosen:
    guess = input(str("Please enter a guess for the {} ".format(len(display)) + "letter word: "))#[0]
    guess = guess.lower()
    #Add the players guess to the list of used letters
    used.extend(guess)
    print ("Attempts: ")
    print (attempts)

    print(wordChosen) # Added for testing

    # Provide a hint if unsuccessful after 7 attempts
    if attempts >= 7 and guess != wordChosen and wordChosen in wordList[0:6]:
      print("HINT: It's an animal")
if attempts >= 7 and guess != wordChosen and wordChosen[0:6]:
if attempts >= 7 and guess != wordChosen and wordChosen in wordList[0:6]:
-----------------------
# Create a list of hangman words
  wordList = ["cat","dog","mouse", "giraffe", "otter", "shark", "sheep", "car", "motorbike",
  "bus", "aeroplane", "pizza", "chips", "cheese"]

# Choose a word from the list at random
  wordChosen = random.choice(wordList)

# Keep asking the player until all letters are guessed
  while display != wordChosen:
    guess = input(str("Please enter a guess for the {} ".format(len(display)) + "letter word: "))#[0]
    guess = guess.lower()
    #Add the players guess to the list of used letters
    used.extend(guess)
    print ("Attempts: ")
    print (attempts)

    print(wordChosen) # Added for testing

    # Provide a hint if unsuccessful after 7 attempts
    if attempts >= 7 and guess != wordChosen and wordChosen in wordList[0:6]:
      print("HINT: It's an animal")
if attempts >= 7 and guess != wordChosen and wordChosen[0:6]:
if attempts >= 7 and guess != wordChosen and wordChosen in wordList[0:6]:
-----------------------
# Create a list of hangman words
  wordList = ["cat","dog","mouse", "giraffe", "otter", "shark", "sheep", "car", "motorbike",
  "bus", "aeroplane", "pizza", "chips", "cheese"]

# Choose a word from the list at random
  wordChosen = random.choice(wordList)

# Keep asking the player until all letters are guessed
  while display != wordChosen:
    guess = input(str("Please enter a guess for the {} ".format(len(display)) + "letter word: "))#[0]
    guess = guess.lower()
    #Add the players guess to the list of used letters
    used.extend(guess)
    print ("Attempts: ")
    print (attempts)

    print(wordChosen) # Added for testing

    # Provide a hint if unsuccessful after 7 attempts
    if attempts >= 7 and guess != wordChosen and wordChosen in wordList[0:6]:
      print("HINT: It's an animal")
if attempts >= 7 and guess != wordChosen and wordChosen[0:6]:
if attempts >= 7 and guess != wordChosen and wordChosen in wordList[0:6]:

How do I change a dataframe in a nested list to a list

copy iconCopydownload iconDownload
library(rrapply)

lst <- rrapply(activities, how = "unmelt")

str(lst, list.len = 3)

#> List of 6
#>  $ Recreational fishing    :List of 26
#>   ..$ Boat                   : chr "Cray pot"
#>   ..$ Boat                   : chr "Hand/rod & line"
#>   ..$ Boat                   : chr "Cray loop"
#>   .. [list output truncated]
#>  $ Recreational - other    :List of 25
#>   ..$ Motorised water sports    : chr "Jet Skiing"
#>   ..$ Motorised water sports    : chr "Boating"
#>   ..$ Motorised water sports    : chr "Water skiing/Knee boarding/Wake boarding"
#>   .. [list output truncated]
#>  $ Commercial fishing      :List of 17
#>   ..$ Roes/Greenlip/Brownlip Abalone Fishery                                   : chr "Hand collection (dive)"
#>   ..$ South Coast Crustacean Managed Fishery (do we need to include the zones?): chr "Pot fishery"
#>   ..$ South Coast Estuarine Management Fishery                                 : chr "Gill Net"
#>   .. [list output truncated]
#>   [list output truncated]
lst1 <- rrapply(cbind(activities, newcol = ""), how = "unmelt")

str(lst1, list.len = 2)

#> List of 6
#>  $ Recreational fishing    :List of 5
#>   ..$ Boat                   :List of 6
#>   .. ..$ Cray pot       : chr ""
#>   .. ..$ Hand/rod & line: chr ""
#>   .. .. [list output truncated]
#>   ..$ Jetty                  :List of 4
#>   .. ..$ Hand/rod & line: chr ""
#>   .. ..$ Cray loop      : chr ""
#>   .. .. [list output truncated]
#>   .. [list output truncated]
#>  $ Recreational - other    :List of 6
#>   ..$ Motorised water sports    :List of 4
#>   .. ..$ Jet Skiing                              : chr ""
#>   .. ..$ Boating                                 : chr ""
#>   .. .. [list output truncated]
#>   ..$ Non-motorised water sports:List of 4
#>   .. ..$ Sailing                    : chr ""
#>   .. ..$ Surfing                    : chr ""
#>   .. .. [list output truncated]
#>   .. [list output truncated]
#>   [list output truncated]
-----------------------
library(rrapply)

lst <- rrapply(activities, how = "unmelt")

str(lst, list.len = 3)

#> List of 6
#>  $ Recreational fishing    :List of 26
#>   ..$ Boat                   : chr "Cray pot"
#>   ..$ Boat                   : chr "Hand/rod & line"
#>   ..$ Boat                   : chr "Cray loop"
#>   .. [list output truncated]
#>  $ Recreational - other    :List of 25
#>   ..$ Motorised water sports    : chr "Jet Skiing"
#>   ..$ Motorised water sports    : chr "Boating"
#>   ..$ Motorised water sports    : chr "Water skiing/Knee boarding/Wake boarding"
#>   .. [list output truncated]
#>  $ Commercial fishing      :List of 17
#>   ..$ Roes/Greenlip/Brownlip Abalone Fishery                                   : chr "Hand collection (dive)"
#>   ..$ South Coast Crustacean Managed Fishery (do we need to include the zones?): chr "Pot fishery"
#>   ..$ South Coast Estuarine Management Fishery                                 : chr "Gill Net"
#>   .. [list output truncated]
#>   [list output truncated]
lst1 <- rrapply(cbind(activities, newcol = ""), how = "unmelt")

str(lst1, list.len = 2)

#> List of 6
#>  $ Recreational fishing    :List of 5
#>   ..$ Boat                   :List of 6
#>   .. ..$ Cray pot       : chr ""
#>   .. ..$ Hand/rod & line: chr ""
#>   .. .. [list output truncated]
#>   ..$ Jetty                  :List of 4
#>   .. ..$ Hand/rod & line: chr ""
#>   .. ..$ Cray loop      : chr ""
#>   .. .. [list output truncated]
#>   .. [list output truncated]
#>  $ Recreational - other    :List of 6
#>   ..$ Motorised water sports    :List of 4
#>   .. ..$ Jet Skiing                              : chr ""
#>   .. ..$ Boating                                 : chr ""
#>   .. .. [list output truncated]
#>   ..$ Non-motorised water sports:List of 4
#>   .. ..$ Sailing                    : chr ""
#>   .. ..$ Surfing                    : chr ""
#>   .. .. [list output truncated]
#>   .. [list output truncated]
#>   [list output truncated]

select-string use in a for-each loop

copy iconCopydownload iconDownload
Get-Childitem -path "C:\PathToFolder" -recurse | Foreach-Object {
    $hostname_import = select-string $_.Fullname -Pattern 'hostname ABC-.+'
    $hostname = $hostname_import -replace '.+ ',''
    
    # The rest of your logic goes here
}
-----------------------
Get-ChildItem -File -Recurse -Filter *.config |
  Select-String -Pattern 'hostname ABC-(.+)' |
   ForEach-Object {
     $sourceFilePath = $_.Path
     $hostName = $_.Matches[0].Groups[1].Value
   }

Find all combinations of strings up to given character length

copy iconCopydownload iconDownload
s, m_s = ['Lion','Rabbit','Sea Otter','Monkey','Eagle','Rat'], 14
def get_combos(d, c = []):
   yield ','.join(c) #yield back valid combination
   for i in range(len(d)):
       if d[i] not in c and len(','.join(c+[d[i]])) <= m_s:
          yield from get_combos(d[:i]+d[i+1:], c+[d[i]]) #found a new valid combination
       if len(d[i]) <= m_s:
          yield from get_combos(d[:i]+d[i+1:], [d[i]]) #ignore running combo and replace with new single string
       yield from get_combos(d[:i]+d[i+1:], c) #ignore string at current iteration of `for` loop and keep the running combination

_, *vals = set(get_combos(s))
print(vals)
['Rat,Rabbit', 'Lion,Rabbit', 'Eagle', 'Eagle,Lion,Rat', 'Monkey', 'Rabbit,Lion', 'Rat,Eagle', 'Sea Otter', 'Rat,Lion,Eagle', 'Monkey,Rat', 'Rabbit,Monkey', 'Sea Otter,Rat', 'Rabbit', 'Lion,Sea Otter', 'Rabbit,Eagle', 'Rat,Eagle,Lion', 'Rat,Sea Otter', 'Lion,Monkey', 'Eagle,Lion', 'Eagle,Rat', 'Lion,Eagle,Rat', 'Rat', 'Lion,Rat,Eagle', 'Eagle,Rabbit', 'Rat,Lion', 'Monkey,Eagle', 'Lion,Eagle', 'Eagle,Monkey', 'Monkey,Lion', 'Rat,Monkey', 'Sea Otter,Lion', 'Rabbit,Rat', 'Monkey,Rabbit', 'Eagle,Rat,Lion', 'Lion,Rat', 'Lion']       
-----------------------
s, m_s = ['Lion','Rabbit','Sea Otter','Monkey','Eagle','Rat'], 14
def get_combos(d, c = []):
   yield ','.join(c) #yield back valid combination
   for i in range(len(d)):
       if d[i] not in c and len(','.join(c+[d[i]])) <= m_s:
          yield from get_combos(d[:i]+d[i+1:], c+[d[i]]) #found a new valid combination
       if len(d[i]) <= m_s:
          yield from get_combos(d[:i]+d[i+1:], [d[i]]) #ignore running combo and replace with new single string
       yield from get_combos(d[:i]+d[i+1:], c) #ignore string at current iteration of `for` loop and keep the running combination

_, *vals = set(get_combos(s))
print(vals)
['Rat,Rabbit', 'Lion,Rabbit', 'Eagle', 'Eagle,Lion,Rat', 'Monkey', 'Rabbit,Lion', 'Rat,Eagle', 'Sea Otter', 'Rat,Lion,Eagle', 'Monkey,Rat', 'Rabbit,Monkey', 'Sea Otter,Rat', 'Rabbit', 'Lion,Sea Otter', 'Rabbit,Eagle', 'Rat,Eagle,Lion', 'Rat,Sea Otter', 'Lion,Monkey', 'Eagle,Lion', 'Eagle,Rat', 'Lion,Eagle,Rat', 'Rat', 'Lion,Rat,Eagle', 'Eagle,Rabbit', 'Rat,Lion', 'Monkey,Eagle', 'Lion,Eagle', 'Eagle,Monkey', 'Monkey,Lion', 'Rat,Monkey', 'Sea Otter,Lion', 'Rabbit,Rat', 'Monkey,Rabbit', 'Eagle,Rat,Lion', 'Lion,Rat', 'Lion']       
-----------------------
import itertools

lst = ['Lion','Rabbit','Sea Otter','Monkey','Eagle','Rat']
sorted_lst = sorted(lst, key=len)

#find max number of items
for n, i in enumerate(sorted_lst):
    if len(','.join(sorted_lst[:n+1])) > 14:
        items_limit = n+1
        break

[x for l in range(1, items_limit) for x in itertools.combinations(lst, l) if len(','.join(x))<15]

how to make docker keep running in frontend and not exit so that I could see the running log output

copy iconCopydownload iconDownload
tail -f /dev/null
-----------------------
docker run -it -d -p 11110:11110 -p 11111:11111 -p 11112:11112 --name canal-server canal/canal-server:v1.1.5 tail -f /dev/null

R Markdown how to make parameter optional

copy iconCopydownload iconDownload
---
title: "`r params$name`"
date: \`r format(Sys.Date(), "%B %d, %Y")`\
output:
  html_document:
    toc: true
params:
    A: NA
    B: NA
    C: NA
    name: NA
--- 
# Header-1

`r params$A` 
`r params$B`
`r params$C`
rmarkdown::render(input = "mytemplate.Rmd", 
       output_file = "fileout.html", 
       params = list(
         name = 'Bob', 
         A = 'turkey', 
         B = 'otter'
       )
)
`r params$A` 
`r params$B`
```{r, echo=FALSE, out.width="50%"}
if(params$C != 'NA') knitr::include_graphics(params$C)
-----------------------
---
title: "`r params$name`"
date: \`r format(Sys.Date(), "%B %d, %Y")`\
output:
  html_document:
    toc: true
params:
    A: NA
    B: NA
    C: NA
    name: NA
--- 
# Header-1

`r params$A` 
`r params$B`
`r params$C`
rmarkdown::render(input = "mytemplate.Rmd", 
       output_file = "fileout.html", 
       params = list(
         name = 'Bob', 
         A = 'turkey', 
         B = 'otter'
       )
)
`r params$A` 
`r params$B`
```{r, echo=FALSE, out.width="50%"}
if(params$C != 'NA') knitr::include_graphics(params$C)
-----------------------
---
title: "`r params$name`"
date: \`r format(Sys.Date(), "%B %d, %Y")`\
output:
  html_document:
    toc: true
params:
    A: NA
    B: NA
    C: NA
    name: NA
--- 
# Header-1

`r params$A` 
`r params$B`
`r params$C`
rmarkdown::render(input = "mytemplate.Rmd", 
       output_file = "fileout.html", 
       params = list(
         name = 'Bob', 
         A = 'turkey', 
         B = 'otter'
       )
)
`r params$A` 
`r params$B`
```{r, echo=FALSE, out.width="50%"}
if(params$C != 'NA') knitr::include_graphics(params$C)

Community Discussions

Trending Discussions on otter
  • HTML Agility Pack foreach loop not iterating for data grid (C#)
  • Why isn't there space between my menu items?
  • how do I use &quot;this&quot; on an component function in react?
  • Can I see all attributes of a pyplot without showing the graph?
  • How do I check against the first 7 elements of the list in order to print some text?
  • Why does Intent.ACTION_MAIN require android.permission.MANAGE_USERS on some devices?
  • How do I change a dataframe in a nested list to a list
  • select-string use in a for-each loop
  • Find all combinations of strings up to given character length
  • how to make docker keep running in frontend and not exit so that I could see the running log output
Trending Discussions on otter

QUESTION

HTML Agility Pack foreach loop not iterating for data grid (C#)

Asked 2022-Mar-13 at 15:48

I'm a beginner programmer working on a small webscraper in C#. The purpose is to take a hospital's public website, grab the data for each doctor, their department, phone and diploma info, and display it in a Data Grid View. It's a public website, and as far as I'm concerned, the website's robots.txt allows this, so I left everything in the code as it is.

I am able to grab each data (name, department, phone, diploma) separately, and can successfully display them in a text box.

// THIS WORKS:
            string text = "";
            foreach (var nodes in full)
            {
                text += nodes.InnerText + "\r\n";
            }
            textBox1.Text = text;

However, when I try to pass the data on to the data grid view using a class, the foreach loop only goes through the first name and fills the data grid with that.

foreach (var nodes in full)
            {
                var Doctor = new Doctor
                {
                    Col1 = full[0].InnerText,
                    Col2 = full[1].InnerText,
                    Col3 = full[2].InnerText,
                    Col4 = full[3].InnerText,
                };
                Doctors.Add(Doctor);
            }

I spent a good few hours looking for solutions but none of what I've found have been working, and I'm at the point where I can't decide if I messed up the foreach loop somehow, or if I'm not doing something according to HTML Agility Pack's rules. It lets me iterate through for the textbox, but not the foreach. Changing full[0] to nodes[0] or nodes.InnerText doesn't seem to solve it either.

link to public gist file (where you can see my whole code)

screenshot

Thank you for the help in advance!

ANSWER

Answered 2022-Mar-13 at 15:48

The problem is how you're selecting the nodes from the page. full contains all individual names, departments etc. in a flat list, which means full[0] is the name of the first doctor while full[4] is the name of the next. Your for-loop doesn't take that into account, as you (for every node) always access full[0] to full[3] - so, only the properties of the first doctor.

To make your code more readable I'd split it up a bit to first make a list of all the card-elements for each doctor and then select the individual parts within the loop:

HtmlWeb web = new HtmlWeb();

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc = web.Load("https://klinikaikozpont.unideb.hu/doctor_finder");

const string doctorListItem = "div[contains(@class, 'doctor-list-item-model')]";
const string cardContent = "div[contains(@class, 'card-content')]";
var doctorCards = doc.DocumentNode.SelectNodes($"//{doctorListItem}/{cardContent}");

var doctors = new List<Doctor>();
foreach (var card in doctorCards)
{
    var name = card.SelectSingleNode("./h3")?.InnerText;
    const string departmentNode = "div[contains(@class, 'department-name')]";
    var department = card.SelectSingleNode($"./{departmentNode}/p")?.InnerText;
    // other proprties...

    doctors.Add(new Doctor{NameAndTitle = name, Department = department});
}

// I took the liberty to make this class easier to understand
public class Doctor
{
    public string NameAndTitle { get; set; }
    public string Department { get; set; }
    // Add other properties
}

Check out the code in action.

Source https://stackoverflow.com/questions/71457516

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install otter

You can download it from GitHub, Maven.
You can use otter like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the otter component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.