FofaClient

Struct FofaClient 

Source
pub struct FofaClient {
    pub key: String,
    pub fields: String,
    pub query_string: String,
    pub size: u32,
}
Expand description

请求客户端的数据结构,这里的page单独以一个usize传入到search,提供遍历

Fields§

§key: String§fields: String§query_string: String§size: u32

Implementations§

Source§

impl FofaClient

Source

pub async fn search(&self, page: u16) -> Result<FofaApiSearch, Error>

大批量调用的情况下使用search接口多些,host聚合用的不多 所以这里就只写了search接口调用 Usage: let client = fofa::FofaClient {…..}; client.search(1); //1是页数,第几页

Source

pub fn get_consumed_fpoint(&self, raw_response: &FofaApiSearch) -> u16

获取剩余F点数量,返回一个u16

Source

pub fn get_required_fpoints(&self, raw_response: &FofaApiSearch) -> u16

获取本次查询需要的F点数量,返回一个u16

Source

pub fn get_size(&self, raw_response: &FofaApiSearch) -> u32

获取本次查询结果的数据总条数,返回一个u32

Source

pub fn get_mode(&self, raw_response: &FofaApiSearch) -> String

获取本次查询执行的接口,返回String

Source

pub fn get_query(&self, raw_response: &FofaApiSearch) -> String

获取本次查询传入的查询语句,返回String

Source

pub fn get_results(&self, raw_response: &FofaApiSearch) -> Vec<Vec<String>>

获取到API返回的result,这里使用Vec<Vec<String>>来存,也就是[[..]:[..],[..]:[..],…]这样的JSON 这里没有经过url_escape,在做GUI的时候记得添加,不然会乱码,返回Vec<Vec<String>>

Source

pub fn get_lines( &self, raw_response: &FofaApiSearch, start: usize, end: usize, ) -> Vec<Vec<String>>

按结果中的行获取数据,返回result

Source

pub fn get_fields_in_range( &self, selected_fields: String, raw_response: &FofaApiSearch, ) -> Vec<String>

把传入的Vec<Vec<String>>转换成一个Hashmap,供输入字段进行查询,这里考虑过使用数学方法(遍历pop)降低时间复杂度到O(n) 但是后来觉得还是直观一点比较好,返回的是一个Fofaclient,O(n^2)

Source

pub async fn get_selected_pages( &self, start: u16, end: u16, ) -> Result<Vec<Vec<String>>, Error>

调用search函数,获取search的response并拼接,返回Vec<Vec<String>>,O(n)

Source

pub fn write_data_to_excel( &mut self, location: String, pages: u16, raw_response: &Vec<Vec<String>>, ) -> Result<(), XlsxError>

遍历Vec<Vec<String>>并写入xlsx,O(n)

Source

pub fn write_data_to_json( &self, location: String, raw_response: &Vec<Vec<String>>, )

将数据写入到json,O(n)

Source

pub fn gettime() -> u64

获取当前时间戳的函数,返回u64

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more