Skip to content

Commit 2932a06

Browse files
committed
chore(chrome): fix outer_html target
1 parent 64f1650 commit 2932a06

File tree

11 files changed

+43
-21
lines changed

11 files changed

+43
-21
lines changed

Diff for: Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: examples/chrome.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! `cargo run --example chrome --features chrome`
1+
//! cargo run --example chrome --features chrome
22
33
extern crate spider;
44
use spider::features::chrome_common::RequestInterceptConfiguration;

Diff for: spider/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spider"
3-
version = "2.27.36"
3+
version = "2.27.37"
44
authors = [
55
"j-mendez <[email protected]>"
66
]

Diff for: spider_chrome/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spider_chrome"
3-
version = "2.27.36"
3+
version = "2.27.37"
44
rust-version = "1.70"
55
authors = [
66
"j-mendez <[email protected]>"

Diff for: spider_chrome/src/element.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ impl Element {
4141
.execute(
4242
DescribeNodeParams::builder()
4343
.node_id(node_id)
44-
.depth(100)
44+
.depth(-1)
45+
.pierce(true)
4546
.build(),
4647
)
4748
.await?
@@ -61,6 +62,7 @@ impl Element {
6162
.object
6263
.object_id
6364
.ok_or_else(|| CdpError::msg(format!("No object Id found for {node_id:?}")))?;
65+
6466
Ok(Self {
6567
remote_object_id,
6668
backend_node_id,

Diff for: spider_chrome/src/handler/page.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use futures::{SinkExt, StreamExt};
77

88
use chromiumoxide_cdp::cdp::browser_protocol::browser::{GetVersionParams, GetVersionReturns};
99
use chromiumoxide_cdp::cdp::browser_protocol::dom::{
10-
DiscardSearchResultsParams, GetOuterHtmlParams, GetSearchResultsParams, NodeId,
10+
BackendNodeId, DiscardSearchResultsParams, GetOuterHtmlParams, GetSearchResultsParams, NodeId,
1111
PerformSearchParams, QuerySelectorAllParams, QuerySelectorParams, Rgba,
1212
};
1313
use chromiumoxide_cdp::cdp::browser_protocol::emulation::{
@@ -127,9 +127,17 @@ impl PageInner {
127127
}
128128

129129
/// Returns the outer html of the page.
130-
pub async fn outer_html(&self, node: NodeId) -> Result<String> {
130+
pub async fn outer_html(
131+
&self,
132+
object_id: RemoteObjectId,
133+
node_id: NodeId,
134+
backend_node_id: BackendNodeId,
135+
) -> Result<String> {
131136
let mut cmd = GetOuterHtmlParams::default();
132-
cmd.node_id = Some(node);
137+
138+
cmd.backend_node_id = Some(backend_node_id);
139+
cmd.node_id = Some(node_id);
140+
cmd.object_id = Some(object_id);
133141

134142
Ok(self.execute(cmd).await?.outer_html.to_string())
135143
}

Diff for: spider_chrome/src/page.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,12 @@ impl Page {
514514
/// # Note: This does not return the actual HTML document of the page. To
515515
/// retrieve the HTML content of the page see `Page::content`.
516516
pub async fn get_document(&self) -> Result<Node> {
517-
let resp = self.execute(GetDocumentParams::default()).await?;
517+
let mut cmd = GetDocumentParams::default();
518+
cmd.depth = Some(-1);
519+
cmd.pierce = Some(true);
520+
521+
let resp = self.execute(cmd).await?;
522+
518523
Ok(resp.result.root)
519524
}
520525

@@ -530,8 +535,15 @@ impl Page {
530535

531536
/// Returns the outer HTML of the page.
532537
pub async fn outer_html(&self) -> Result<String> {
533-
let root = self.get_document().await?.node_id;
534-
self.inner.outer_html(root).await
538+
let root = self.get_document().await?;
539+
let element = Element::new(Arc::clone(&self.inner), root.node_id).await?;
540+
self.inner
541+
.outer_html(
542+
element.remote_object_id,
543+
element.node_id,
544+
element.backend_node_id,
545+
)
546+
.await
535547
}
536548

537549
/// Return all `Element`s in the document that match the given selector
@@ -564,7 +576,7 @@ impl Page {
564576
.execute(
565577
DescribeNodeParams::builder()
566578
.node_id(node_id)
567-
.depth(100)
579+
.depth(-1)
568580
.build(),
569581
)
570582
.await?;

Diff for: spider_cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spider_cli"
3-
version = "2.27.36"
3+
version = "2.27.37"
44
authors = [
55
"j-mendez <[email protected]>"
66
]

Diff for: spider_transformations/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spider_transformations"
3-
version = "2.27.36"
3+
version = "2.27.37"
44
authors = [
55
"j-mendez <[email protected]>"
66
]

Diff for: spider_utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spider_utils"
3-
version = "2.27.36"
3+
version = "2.27.37"
44
authors = [
55
"j-mendez <[email protected]>"
66
]

Diff for: spider_worker/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spider_worker"
3-
version = "2.27.36"
3+
version = "2.27.37"
44
authors = [
55
"j-mendez <[email protected]>"
66
]

0 commit comments

Comments
 (0)